# Unity-Command-System **Repository Path**: River314588804/unity-command-system ## Basic Information - **Project Name**: Unity-Command-System - **Description**: 适用于 Unity 平台的简易命令行框架 - **Primary Language**: Unknown - **License**: GPL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2025-03-31 - **Last Updated**: 2025-12-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: command, Unity, 工具 ## README # Unity-Command-System | 命令系统 ___ [![](https://img.shields.io/badge/不定期-更新中-green)]() [![](https://img.shields.io/badge/支持-Unity6.0-green)]() [![](https://img.shields.io/badge/支持-全平台-white)]() [![fa](https://img.shields.io/badge/发行版-v1.0.0-red)]() #### 项目描述 这是一个服务于开发者测试用的基础命令系统。   #### 快速部署 前往 发行版 下载 .unitypackage 即可。   #### 快速上手 1. 你需要在 Unity 生命周期中手动执行一次 `Init()` 以初始化命令集。 ```csharp public void Start() { // 挂载 CommandManager.cs 或 new() 方式 CommandManager _commandMgr = _commandMgr.Init(); } ``` ps:你只需要创建你的命令脚本类,CommandManager 会在生命周期开始时检索继承 ICommand 接口的所有类并实例化。   #### 创建命令 你可以选择新建脚本继承 `RStudio.Command.ICommand` 以实现接口。示例如下: ```csharp using RStudio.Command; public class CommandHello : ICommand { public string Name => "AdminBroadcast"; public string Description => "使用全局广播"; public CommandPermission RequiredPermission => CommandPermission.Normal; public string Category => "General"; public string Usage => "AdminBroadcast [参数]"; public string[] ParamArray { get; set; } = System.Array.Empty(); public bool CanExecute(string[] args) { // 制定你的规则决定是否允许执行 // 你可以选择在 Execute(string[] args) 中直接判断。 return this.ParamArry.Length == args.Length; } public bool Execute(string[] args) { if (!CanExecute(args)) return false; Debug.Log("Hello World!"); return true; } } ``` 你也可以选择菜单 **RStudio/命令系统/命令生成器** 在图形化界面中创建脚本。 该图形化界面的优势 1. 检索是否有已创建命令,避免冲突。 2. 快速浏览和索引具体命令,方便修改。 ![输入图片说明](https://foruda.gitee.com/images/1760452764157529500/b6cec097_14180433.png "屏幕截图")