Mirage Console

In-game command console and debug tools for Unity.

An in-game console for Unity: turn a C# method into a command with one attribute.

Run it from a command line, a button or your own code, read every message your game logs, keep an eye on performance, and send the logs of a bug to your team, all inside the running game, in the Editor and in your Development builds.

> @Enemy* heal 20

Open the consoleCreate your first command

The console open over a game, on its CLI tab.
The console open over a game, on its CLI tab.

What you get

Requirements

  • Unity 2022.3.62f3 or newer (the console is drawn with UI Toolkit at runtime).
  • Any render pipeline: Built-in, URP or HDRP.
  • The Legacy Input Manager, the Input System package, or both: the console detects which one to use. The Input System package is optional.

The Unity versions it is tested with, and what it doesn't do, are in Compatibility and limitations.

Tutorial: from install to your first command

This tutorial takes about ten minutes. You will install the package, open the console, find your way around its tabs, then write a command of your own and run it.

Step 1: Install the package

Install the package with the Package Manager:

  1. In Unity, open Window > Package Manager.
  2. In the list on the left, choose My Assets (called Packages: My Assets in older versions), then select Mirage Console.
  3. Click Download, then Install.

That's all the setup there is: the console works out of the box with its default settings. It has no Resources folder and adds nothing to your scenes: it creates itself when the game starts.

Step 2: Open the console

  1. Open any scene and press Play.
  2. Press F12: the console opens over the game. Press F12 again, or Esc, or click the × at the end of the tab bar, to close it.
The console, just opened with F12.
The console, just opened with F12.

Step 3: Find your way around

The console has four tabs. Click a tab to show it:

The tab bar: CLI, All Messages, Commands and Profiling, and the close button.
The tab bar: CLI, All Messages, Commands and Profiling, and the close button.
TabWhat it is for
CLIThe command line: type a command, press Enter, read what it answers. More
All MessagesEvery message your game logs (Debug.Log, warnings, errors, exceptions), filtered by severity and by tag. More
CommandsA button for every command that needs no argument: one click runs it. More
ProfilingFPS, frame time, memory, and a recording you can copy as CSV. More

Now try a few commands in the CLI tab. Type each line, then press Enter:

> list
> help echo
> echo "Hello from the console" -v warning
  • list lists every command, group by group, with what it does.
  • help echo shows how to type echo and what its parameters are.
  • echo writes a message; -v warning writes it as a warning.
What list shows: the commands, group by group.
What list shows: the commands, group by group.

Three keys make the command line fast:

  • Tab completes what you are typing: type he then Tab to get help.
  • ↑ and ↓ bring back what you already typed.
  • Enter runs the entry.

Step 4: Create your first command

A command is a static method with the [Command] attribute. Create a C# script in your Assets folder, name it MyCommands.cs, and replace its content with:

using MI.Console;
using UnityEngine;

public static class MyCommands
{
    [Command("greet")]
    [CommandSummary("Say hello to someone")]
    static void Greet([ParamInfo("Who to greet")] string name = "world")
    {
        Debug.Log($"Hello, {name}!");
    }
}

What each line does:

  • using MI.Console; gives access to the attributes of the console.
  • [Command("greet")] makes the method a command named greet. The method can be private or public.
  • [CommandSummary] is the description that list and help show.
  • The parameter name becomes a parameter of the command. Because it has a default value, it is optional, and it is given by its name: --name. [ParamInfo] describes it for help.

Step 5: Run it

Back in Unity, press Play, open the console and type:

> greet
Hello, world!
> greet --name Alice
Hello, Alice!
> help greet
greet [--name stringValue]
Say hello to someone
    name (text, default "world"): Who to greet
Your first command, run from the CLI.
Your first command, run from the CLI.

Because greet needs no argument, it also has a button in the Commands tab. Open that tab and click greet: it runs as if you had typed it.

The greet command has its own button in the Commands tab.
The greet command has its own button in the Commands tab.

Where to go next