Streamlining Development with CommandConsole
Introduction
As game developers, we often find ourselves grappling with a complex web of code and gameplay elements. Debugging and fine-tuning these elements can be a tedious, time-consuming task. With this in mind I'd like to introduce you to CommandConsole, a tool I developed that aims to simplify the debugging process and enhance Editor workflows. - Check out CommandConsole on GitHub!
Benefits of CommandConsole
The CommandConsole is a modular, user-friendly tool designed to streamline your development workflow within Unity. The core objective of the CommandConsole is to make the task of debugging less of a chore, allowing developers and testers to directly interact with the game environment or perform Editor tasks without needing to implement any new UI or tooling. In doing so, it provides an efficient interface for the implementation and execution of modular commands, significantly enhancing the quality of life for developers.
Command Implementation in CommandConsole
The CommandConsole stands out due to its potential for customization. It provides developers with the freedom to implement any commands they need to aid in debugging or interacting with the Editor. For instance, one of the most commonly useful commands I've implemented is the 'timescale' command. This command can both display and alter Unity's Time.timeScale property, a commonly altered value when debugging virtually any Unity project. Look how easily this command is implemented and exposed for execution within the CommandConsole framework.
Github Code Section
gh-repo="BIRD-COMMAND/CommandConsole"
gh-branch="main"
gh-file="Assets/Editor/CommandConsole/TimescaleCommand.cs"
gh-start="3" gh-end="27"
The Power of Reflection
One of the nice features of the CommandConsole is its use of Reflection to automatically discover and instantiate all commands within a project. This approach enables developers to effortlessly add new commands to the console by simply creating new subclasses of the ConsoleCommand
base class.
Github Code Section
gh-repo="BIRD-COMMAND/CommandConsole"
gh-branch="main"
gh-file="Assets/Editor/CommandConsole/CommandConsole.cs"
gh-start="68" gh-end="79"
Coroutine Support
The CommandConsole also provides comprehensive support for Coroutine-based commands. This enables the implementation of commands that require continuous execution. For instance, the velocity
command periodically draws a representation of the velocity of all Rigidbody2Ds in the scene. To facilitate this, the ConsoleCommand
base class integrates with a small utility class, CoroutineUtil
, which offers a simplified interface for creating and managing Coroutines within non-MonoBehaviour classes.
Github Code Section
gh-repo="BIRD-COMMAND/CommandConsole"
gh-branch="main"
gh-file="Assets/Editor/CommandConsole/VisualizeVelocityCommand.cs"
gh-start="9" gh-end="28"
CommandConsole In Action
To demonstrate the capabilities of the CommandConsole, I've prepared a small, dynamic demo scene where I manipulate the game environment using a few of the default commands I’ve implemented.
Future Prospects and Contribution
The current version of CommandConsole already has a lot to offer, but there's always room for improvement. I'm excited to see how this tool evolves with community input and involvement. Whether it's adding new commands, tweaking existing ones, or even enhancing the core functionality of the CommandConsole itself, every contribution helps make this tool even better.
The CommandConsole was borne out of a desire to make Unity development smoother and more enjoyable. It provides an efficient and flexible interface for implementing and executing commands, making it a potent addition to any Unity developer's toolkit. Whatever your use case, the CommandConsole is here to make the process a little bit easier, and as seamless as possible. I invite you to check out the CommandConsole on GitHub, experiment with it, and see the difference it can make to your development workflow!