Custom Commands & IntelliSense

Registering Custom Commands

Creating a custom command is as simple as adding the [Command] attribute to any method in your game, whether it’s static or part of a MonoBehaviour.

using DevConsole;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    // The method will be automatically discovered on startup!
    [Command("spawn.enemy", "Spawns an enemy at the player's position.")]
    public static void SpawnEnemy(string type, int count)
    {
        // Your logic here.
    }
}

Event-like Execution with SharedCommands

If you want to invoke multiple methods across entirely different scripts simultaneously using the exact same command name, use the [SharedCommand] attribute! This acts like an event broadcast.

You can also precisely control the execution order using the Order property. Methods with lower Order values execute first. If Order is not defined, the system automatically runs them last, sorting them alphabetically by their script name, and prints a warning in the console log.

public class GameManager : MonoBehaviour
{
    [SharedCommand("save.all", Order = 1)]
    public static void SaveGameWorld()
    {
        // Executes first
    }
}

public class InventoryManager : MonoBehaviour
{
    [SharedCommand("save.all", Order = 2)]
    public static void SavePlayerInventory()
    {
        // Executes after the GameManager
    }
}

Multi-Instance Commands (InstanceMode)

When a [Command] is placed on a non-static method of a MonoBehaviour that has many instances in the scene (e.g., 30 enemies), you need to control which instance runs the command. Use the InstanceMode property:

public class EnemyAI : MonoBehaviour
{
    // Default: Runs on the first found. Logs a warning if multiple exist.
    [Command("enemy.attack")]
    public void Attack() { /* ... */ }

    // Runs on ALL instances in the scene simultaneously.
    [Command("enemy.heal", InstanceMode = CommandInstanceMode.AllInstances)]
    public void HealAll() { /* ... */ }

    // User must specify which GameObject to target as the first argument.
    // e.g., typing "enemy.inspect Goblin_01" targets only that specific one.
    [Command("enemy.inspect", InstanceMode = CommandInstanceMode.ByGameObjectName)]
    public void Inspect() { /* ... */ }
}
ModeBehavior
FirstFoundRuns on the first instance found. Logs a warning if multiple instances exist, showing which one was selected.
AllInstancesRuns the command on every instance in the scene, similar to SharedCommand.
ByGameObjectNameRequires the user to type the target GameObject’s name as the first argument. IntelliSense suggests valid targets.

Supported Parameter Types

The Dev Console Pro handles type conversion natively for almost every common Unity type without requiring any boilerplate parsing code.

TypeExamples & Native Support
Primitivesint, float, double, decimal, string, bool (supports 1/0 and true/false).
EnumsNative support. Just use your Enum as the parameter type and type its name (e.g. EnemyType.Orc).
VectorsVector2, Vector3. Use syntax like new(0, 1.5, 0), Vector3.down, or [0, 1.5, 0].
ArraysPass arrays using bracket syntax: spawn [goblin, orc, troll].
ColorsNative support. Parsed via Unity’s HTML parser (e.g., red, cyan, #FF00FF).
GameObjectsPass GameObjects by name. Type Enemy and the console automatically finds GameObject.Find("Enemy").
ComponentsLook up components natively using GoName:ComponentType (e.g. Player:Rigidbody2D).

Parameter IntelliSense (Autocomplete)

The Dev Console Pro features a powerful contextual suggestion engine. When the user types a command, it can suggest valid values for each specific parameter dynamically.

Option A: Automatic Type Inference (Zero Setup)

If you do nothing, the console automatically infers suggestion types for parameters!

[Command("set.god.mode")]
public static void SetGodMode(bool enabled, KeyCode triggerKey, EnemyType enemyEnum, Color glowColor) 
{
    // Automatically suggests 'true'/'false' for enabled.
    // Automatically suggests Unity KeyCode list for triggerKey.
    // Automatically suggests EnemyType values for enemyEnum.
    // Automatically suggests basic color names (red, blue...) for glowColor.
}

Note: String parameters with names like sceneName or layer will also be automatically inferred.

Option B: Method-level Attributes

For simple cases, you can provide an array of SuggestionType values directly in the [Command] attribute:

[Command("teleport", "Teleport to a GameObject", ParameterSuggestions = new[] { SuggestionType.GameObject })]
public static void Teleport(string target)
{
    // Typing "teleport " will suggest scene GameObjects
}

Option C: Per-Parameter Attributes

If you need complex suggestions (like suggesting GameObjects that only have a specific component attached), use the [CommandParamSuggestion] attribute.

[Command("find", "Find objects with a specific component")]
public static void Find(
    [CommandParamSuggestion(SuggestionType.Component, typeof(Rigidbody2D))] string objectName)
{
    // The console will only suggest GameObjects that actually have a Rigidbody2D!
}

Option D: Custom Dynamic Providers & Reverse Lookup

You can provide your own dynamically generated lists of suggestions. Even better, if you use the Generic provider overload, the console will automatically map the strings in the UI back to actual object instances at execution time!

1. Register the provider (e.g., in Awake):

// Passing a generic provider will automatically convert values to strings for UI
// AND it will automatically resolve the exact object instance during execution!
SuggestionProvider.RegisterCustomProvider<ScriptableRendererFeature>("render_features", () => myRendererData.rendererFeatures);

2. Use the Custom ID in your command:

[Command("renderer.toggle")]
public static void ToggleFeature([CommandParamSuggestion("render_features")] ScriptableRendererFeature feature)
{
    // When you type "renderer.toggle ", it auto-suggests the names of the features.
    // When you hit enter, the actual 'feature' object reference is safely injected here!
    feature.SetActive(!feature.isActive);
}

List of Suggestion Types

Here is the complete list of available SuggestionType enum values you can use:

TypeSuggestsCaching
NoneNo suggestions (default)
GameObjectActive scene GameObjects0.5s
ComponentGameObjects with a specific component (requires typeof(T))1.0s per type
CommandNameRegistered console command namesAlways fresh
KeyCodeUnity KeyCode enum valuesOnce
CustomEnumValues from the parameter’s enum typeInstant
Bool / Booleantrue / falseStatic
SceneNameScenes added to the Build SettingsOnce
TagUnity tags (built-in + custom)Once
LayerNon-empty layer names (0–31)Once
CustomYour own dynamically generated lists via string IDInstant
Vector2Standard Vector2 constants (e.g., Vector2.up)Static
Vector3Standard Vector3 constants (e.g., Vector3.forward)Static
ColorStandard HTML color names (red, cyan, blue, etc.)Static

Advanced Parsing Features

  • Multi-Word Commands: You can include spaces in command names (e.g., [Command("spawn boss")]). The autocomplete seamlessly handles multi-word groupings.
  • Vector Syntax Rendering: Vector values are color-coded in the UI to match Unity’s standard Red/Green/Blue gizmos for absolute visual clarity!
  • Nested Alias Parsing: The robust nested context parser completely prevents autocomplete failures or logic breaks when you are writing complex nested aliases with bracket [ ] syntax.