Skip to content

Commands

Elias Wennerberg edited this page Oct 4, 2026 · 3 revisions

Commands

Anatomy

[ConsoleCommand("coins", Description = "Grants coins.", Flags = CommandFlags.Cheat)]
public static void CoinsCommand(Action<string, bool> response, int amount = 250)
  • Name ("coins") plus optional Group ("application.quit" style: Group = "application").
  • Response callback (optional, first parameter): Action<string>, Action<string, bool>, or CommandResponseDelegate. Skipped for argument indexing in help and autocomplete.
  • Arguments: any convertible type, params arrays, optional defaults.

Flags (CommandFlags)

None, DebugOnly (debug builds only), EditorOnly, Cheat (needs UniTerminal.CheatsEnabled, toggled by the built-in enablecheats command), Hidden (excluded from help), Mod.

Aliases

[ConsoleCommand("help", Description = "...")]
[CommandAlias("h")]

Custom types

UniTerminal.RegisterArgConverter<FoodId>(s => new FoodId(s));

After that, any FoodId parameter parses from a string automatically.

Invoking from code

UniTerminal.ExecuteCommand("coins 500");
UniTerminal.Log("Hello console.");

Built-ins

help [command], clear, toggleUnityLogs, plus optional packs (time scale, graphics, physics, prefs, system info) toggled in Tools → UniTerminal → UniTerminal Window.

Examples

[ConsoleCommand("wave", Description = "Reports the current wave number.")]
public static void WaveCommand(CommandResponseDelegate response)
{
    var waves = Object.FindFirstObjectByType<WaveManager>();
    response(waves != null ? $"Wave {waves.WaveNumber}." : "No WaveManager in scene.", waves != null);
}

More examples

Grouped command with an alias and a params array:

[ConsoleCommand("give", Description = "Gives items.", Group = "inventory")]
[CommandAlias("g")]
public static void GiveCommand(CommandResponseDelegate reply, params string[] items)
{
    foreach (string item in items)
        Inventory.Add(item);
    reply($"Gave {items.Length} item(s).");
}

Instance command — resolves a scene object instead of a static:

public class Shovel : MonoBehaviour
{
    [ConsoleCommand("beds", Description = "Reports garden bed usage.")]
    public void BedsCommand(CommandResponseDelegate response)
    {
        response($"Beds: {BedCount} / {maxBeds}.", true);
    }
}

Clone this wiki locally