This is a simple in-game console for Unity games. It allows you to easily add commands and execute them at runtime.
- Easy creation of custom commands
- Simple configuration
- Stacktrace output with syntax highlight
- Download the package and put it into
Assets/Addonsfolder in your project. - Add the
Console Canvasprefab fromPrefabsfolder to your scene. - Add Console Opener script to the scene from
Examplesfolder or create a new one. See example. - To create a new command, create a new C# script and inherit from the
Commandclass. See example.
- Unity v. 2020 or newer
- TextMeshPro v. 3.0.5 or newer
You can change console settings in Edit > Project Settings > In-game Console.
There are some example commands: help, log and clear in Examples/Commands folder. Here's an example command that prints specified text to the console:
using InGameConsole;
public class LogCommand : Command
{
public override string Name => "log";
public override string Description => "Writes a specified text message in the console";
public override void Execute(string[] args)
{
if (args.Length == 0)
{
Console.Write("No arguments given.");
return;
}
Console.Write(string.Join(" ", args));
}
}Here's an example console opener for default input system:
private void Update()
{
if (Input.GetKeyDown(KeyCode.F3))
{
Console.OpenOrClose();
}
}Here's an example console opener for Unity Input System:
private void Awake()
{
inputs.Game.Console.performed += _ => Console.OpenOrClose();
}Note: to use the Console class you must use InGameConsole namespace:
using InGameConsole;