Development Console

June 19, 2026 · View on GitHub

An in-game developer console for running debug commands at runtime. Commands are ScriptableObject assets you assign to a DevelopmentConsole component.

See the demo scene: ConsoleDemo.unity.


Setup

  1. Create a GameObject and add the DevelopmentConsole component.
  2. Create command assets via Create > Game:Work > Development > Command > … (or use the assets in Commands).
  3. Drag the command assets into the Commands list on the component.
// DevelopmentConsole inspector
[SerializeField] private KeyCode showKey = KeyCode.Backslash;  // default: \
[SerializeField] private List<DevelopmentCommand> commands;

Using the console

ActionInput
Open consoleshowKey (default \)
Close consoleEscape, showKey, X button, or close command
Run commandType command and press Enter
Command historyUp / Down arrows

Input is trimmed and lowercased before parsing. The first token is matched against each command's Id; remaining tokens are passed as args to Execute.

If a command returns false, the console logs a warning with its Usage string. Unknown commands log Invalid command '…'.


Built-in commands

All built-in commands live in Commands.

quit

Exits the application. In the Editor, stops Play mode instead of quitting Unity.

Idquit
Usagequit
ArgsNone
SourceQuitCommand.cs
quit

close

Hides the development console without quitting the game.

Idclose
Usageclose
ArgsNone
SourceCloseCommand.cs
close

destroy

Destroys every GameObject in the scene whose name matches the argument (case-insensitive). Searches active and inactive objects via Resources.FindObjectsOfTypeAll. Uses SafeDestroy.

Iddestroy
Usagedestroy 'gameobject-name'
Argsname, object name (lowercase)
SourceDestroyCommand.cs
destroy enemy
destroy debug_cube

gameobject

Finds the first GameObject matching the name (case-insensitive, active or inactive) and runs a sub-command on it.

Idgameobject
Usagegameobject 'name' destroy|activate|deactivate|move|rotate [x,y,z]
Argsname, subcommand, optional vector
SourceGameObjectCommand.cs

Sub-commands

Sub-commandArgsEffect
destroy,Destroys the object (DestroyImmediate in Editor, Destroy at runtime)
activate,SetActive(true)
deactivate,SetActive(false)
movex,y,zSets transform.position
rotatex,y,zApplies euler rotation on X, then Y, then Z axes

Vector arguments use comma-separated floats: 1.0,2.0,3.0.

gameobject player activate
gameobject enemy deactivate
gameobject camera move 0,5,-10
gameobject prop rotate 0,90,0
gameobject temp destroy

primitive

Creates a Unity primitive at the world origin, optionally at a given position.

Idprimitive
Usageprimitive cube|sphere|plane|cylinder|capsule [x,y,z]
Argstype, optional position
SourcePrimitiveCommand.cs

Types: cube, sphere, plane, cylinder, capsule.

primitive cube
primitive sphere 0,1,0
primitive capsule 2.5,0,0

Command reference

CommandExampleDescription
quitquitExit app / stop Play mode
closecloseHide the console
destroydestroy enemyDestroy all objects named enemy
gameobjectgameobject player activateOperate on a single named object
primitiveprimitive cube 0,1,0Spawn a primitive

Creating custom commands

Subclass DevelopmentCommand and implement Execute. Return true on success, false to show the Usage hint.

using UnityEngine;

[CreateAssetMenu(fileName = "GodMode", menuName = "Game:Work/Development/Command/GodMode")]
public class GodModeCommand : DevelopmentCommand
{
  public GodModeCommand()
  {
    Id = "godmode";
    Usage = "godmode on|off";
    Description = "Toggle invincibility.";
  }

  public override bool Execute(string[] args)
  {
    if (args.Length != 1)
      return false;

    bool enabled = args[0] == "on";
    PlayerHealth.Invincible = enabled;
    Log.Info($"God mode {(enabled == true ? "enabled" : "disabled")}.");

    return true;
  }
}

Each command asset exposes three serialized fields:

FieldPurpose
IdToken used to invoke the command (matched case-insensitively)
UsageShown when Execute returns false
DescriptionHuman-readable summary (for your own reference)

API

TypeRole
DevelopmentConsoleMonoBehaviour that renders the console and dispatches input
DevelopmentCommandAbstract ScriptableObject base for commands
IDevelopmentCommandCommand contract (Id, Usage, Description, Execute)

Console appearance is configured in Settings.DevelopmentConsole (FontSize, Height, Margin, design resolution).