Skip to content

Polish-Coder/Unity-In-Game-Console

Repository files navigation

Unity In-game Console

This is a simple in-game console for Unity games. It allows you to easily add commands and execute them at runtime.

Features

  • Easy creation of custom commands
  • Simple configuration
  • Stacktrace output with syntax highlight

Console

Getting started

  1. Download the package and put it into Assets/Addons folder in your project.
  2. Add the Console Canvas prefab from Prefabs folder to your scene.
  3. Add Console Opener script to the scene from Examples folder or create a new one. See example.
  4. To create a new command, create a new C# script and inherit from the Command class. See example.

Requirements

  • Unity v. 2020 or newer
  • TextMeshPro v. 3.0.5 or newer

Console Settings

You can change console settings in Edit > Project Settings > In-game Console.

Examples

Commands

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)); } }

Console Openers

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;

About

Simple in-game console for Unity games. It allows you to easily add commands and execute them at runtime.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages