Debug Console
This tool is part of a personal unity package that i have been working on in my free time. As such, if you are curious or want to use some of these tools yourself, you can check the git repo!
In the Unity Engine, a big issue that i often face is the inability to test and verify a finished build effectively due to a lack of a proper console that shows errors. Furthermore, testing specific features can take several hours, leading to slower iterations and an overall longer development time .
To solve these issues, i developed a Debug Console that prints any Unity log as well as allows the user to create custom commands that can be used to test features that would otherwise take time.
Creating a Command System
The first feature developed was a command system. The goal of this feature is to easily add custom cheat commands while allowing for further customization should a need arise.
As such, the API is pretty straight forward. The user has the ability to add commands with the AddCommand
function and even has the option to define a custom argument type with the AddKeyword
as seen here:
Most of the codebase is being compiled only when the user is running the project in the Unity Editor or the user defines DEBUG_BUILD
in the project settings. This ensures that the release version of the game does not have this Debug Console while allowing for individuals to create developer builds for the purposes of testing.
Creating the Debug Console itself
The Command System on its own doesn't do much besides allowing the user to create custom commands. As such, the second feature was to create the console itself.
Using Unity's UIToolkit, i created a template that gets updated in a separate Console.cs component.
The component itself is then instantiated at the start of the runtime whenever the project is run in the editor or when a specific definition is set in the project settings.
This component is responsible for implementing the basics of the console, such as printing the output of debug logs and command print outs as well as managing the input with a handy auto-complete prompt.
The result of developing these two features allowed for faster iteration and testing when developing complex features or enabling extra debug information.