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

Non-static commands

Adding non-static commands

Non-static methods or properties require an instance in order to be executed. Instances are found automatically behind the scenes, which means there is no additional setup required on your part.

public class Player : MonoBehaviour
{
    private float currentHealth;

    [Command]
    public int Health
    {
        get => currentHealth;
        set => currentHealth = value;
    }
}

Typing health 10 will execute on all instances of Player found in the scene.

Additionally, a name can be specified at the end of the input prefixed with @. Doing so will execute the command only on instances with the specified name.

The name is always specified at the end of the last required parameter. So for example, if we want to just print the value of a property instead of setting it, we could type: health @MyPlayer.

PreviousStatic commandsNextDynamic commands

Last updated 7 months ago

Was this helpful?