Ghost Commands
  • Getting Started
    • Quickstart
    • Syntax
      • Command syntax
      • Arguments with multiple values
    • Custom commands
  • Documentation
    • Commands
      • Static commands
      • Non-static commands
      • Dynamic commands
      • Overloads
      • Parameters
      • Additional attributes
    • Suggestions
      • Suggestion attributes
      • Suggestor methods
    • Converters
      • Custom parameter types
      • Using the ArgumentReader
      • Multiple ways to interpret an argument
    • Processors
      • Creating a processor
      • Setting priorities
      • Cheat codes example
    • Macros
    • Settings
    • Customization
    • Included Commands
Powered by GitBook
On this page

Was this helpful?

  1. Documentation
  2. Commands

Additional attributes

PreviousParametersNextSuggestions

Last updated 7 months ago

Was this helpful?

Additional attributes

[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 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.

settings section