CommandAttribute

Attribute that marks a static method as a discoverable command. Methods decorated with [Command] are automatically found by CommandProvider at editor load time and made available through the Command static API.

Definition

Namespace: Paragon Assembly: Paragon.dll

[AttributeUsage(AttributeTargets.Method), MeansImplicitUse]
public class CommandAttribute : Attribute

Inheritance: AttributeCommandAttribute

Remarks

CommandAttribute is the base attribute for the command system. It supports two specializations:

  • RuntimeCommandAttribute — Shorthand for [Command(runtimeOnly: true)], restricts execution to play mode

  • EditorCommandAttribute — Editor-only command (compiled out of builds via #if UNITY_EDITOR)

The Name field controls the registered command name. If null, the CommandProvider uses the method name instead. Spaces in the name are automatically replaced with dashes.

The attribute includes [MeansImplicitUse] (JetBrains annotations) to suppress "unused method" warnings in IDEs since commands are invoked via reflection.

Quick Lookup

Goal
How

Register a command

[Command("command-name")]

Runtime-only command

[RuntimeCommand("command-name")]

Editor-only command

[EditorCommand("command-name")]

Auto-name from method

[Command] (uses method name)

Fields

Name

The registered command name. Spaces are replaced with dashes. If null, the method name is used as the command name.

RuntimeOnly

When true, the command can only be executed during play mode.

Constructors

CommandAttribute

Parameter
Type
Default
Description

name

string

null

Command name (spaces → dashes). null = use method name

runtimeOnly

bool

false

Restrict to play mode execution

Derived Types

RuntimeCommandAttribute

Convenience attribute equivalent to [Command(runtimeOnly: true)].

Parameter
Type
Default
Description

name

string

null

Command name (spaces → dashes)

EditorCommandAttribute

Editor-only command attribute. Compiled out of builds via #if UNITY_EDITOR.

Parameter
Type
Default
Description

name

string

null

Command name (spaces → dashes)

Common Pitfalls

circle-exclamation
circle-exclamation
circle-info

MeansImplicitUse suppresses IDE warnings The [MeansImplicitUse] annotation tells JetBrains IDEs that the method is invoked via reflection, preventing false "unused method" warnings.

Examples

Defining Commands

See Also

  • Command — Static API for executing and searching commands

  • CommandMethod — Wraps attributed methods with runtime metadata

Last updated