您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
46 行
1.5 KiB
46 行
1.5 KiB
namespace UnityConsole
|
|
{
|
|
public struct ConsoleCommandResult
|
|
{
|
|
public bool succeeded;
|
|
public string Output;
|
|
|
|
public static ConsoleCommandResult Failed(string output = null)
|
|
{
|
|
return new ConsoleCommandResult()
|
|
{
|
|
succeeded = false,
|
|
Output = output
|
|
};
|
|
}
|
|
|
|
public static ConsoleCommandResult Succeeded(string output = null)
|
|
{
|
|
return new ConsoleCommandResult()
|
|
{
|
|
succeeded = true,
|
|
Output = output
|
|
};
|
|
}
|
|
}
|
|
|
|
public delegate ConsoleCommandResult ConsoleCommandCallback(params string[] args);
|
|
|
|
public delegate void SimpleConsoleCommandCallback();
|
|
|
|
public struct ConsoleCommand
|
|
{
|
|
public string name { get; private set; }
|
|
public string description { get; private set; }
|
|
public string usage { get; private set; }
|
|
public ConsoleCommandCallback callback { get; private set; }
|
|
|
|
public ConsoleCommand(string name, string description, string usage, ConsoleCommandCallback callback) : this()
|
|
{
|
|
this.name = name;
|
|
this.description = (string.IsNullOrEmpty(description.Trim()) ? "No description provided" : description);
|
|
this.usage = (string.IsNullOrEmpty(usage.Trim()) ? "No usage information provided" : usage);
|
|
this.callback = callback;
|
|
}
|
|
}
|
|
}
|