[Command]
[Description("Gives 5000 coins to the player")]
public static void Motherlode()
{
coins += 5000;
}
Commands can have a description added to them with the [Description] attribute.
To see the description of a command, type help <command name> in the command field.
[Prefix("score")]
public static class ScoreManager
{
[Command]
public static int Current { get; set; }
[Command]
public static void Reset()
{
Current = 0;
}
}
Commands can be organized together by using the [Prefix] attribute on a class, which then groups all the commands in that class under the same prefix.
It can be used on classes, methods or properties.
The above example would result in the commands looking like this in the command field:
The prefix character can be changed in project settings. See the settings section for more details.
[Command]
[EditorOnly]
public static void RefreshAssets()
{
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
Commands can be constrained to only show up in edit-mode, and not be shown in play-mode, with the [EditorOnly] attribute.
It can be used on classes, methods or properties.
[Command]
[RuntimeOnly]
public static void HealPlayers(int amount)
{
Player[] players = FindObjectsByType<Player>(FindObjectsSortMode.None);
foreach (var player in players)
{
player.Health += amount;
}
}
Commands can be constrained to only show up in play-mode, and not be shown in edit-mode, with the [RuntimeOnly] attribute.
It can be used on classes, methods or properties.