O2 Console is an in-game, attribute-driven debug console for Unity that lets developers easily define and execute commands at runtime. Built using Unity’s powerful Reflection API, it dynamically discovers scene objects and registers command methods, providing a flexible and robust tool for live debugging and interaction.
- 
🏷️ Command Attribute System
Mark methods, properties, or fields with[ConsoleCommand("CommandKey")]and the console automatically registers them as commands. - 
🔍 Reflection-Based Registration
Scans all public and private methods, properties, and fields on scene objects during initialization. - 
🔢 Single Parameter Support
Supports commands with up to one parameter (multi-parameter support coming soon!). - 
⚡ Dynamic Command Execution
Execute commands directly from the in-game console UI. - 
🧩 Supports Static & Instance Members
Works seamlessly with static and instance methods, properties, and fields. - 
🎯 Scene Discovery on Load
Automatically discovers objects present when the scene loads; runtime-created objects require manual registration. - 
🔄 Parameter Passing & Conversion
Converts input strings from the console to the correct method parameter types automatically. - 
🛡️ Exception Handling & Logging
Captures exceptions and logs errors cleanly in the console for easier debugging. - 
🚀 Built-in Commands
Includes handy commands like/Clearto clear logs and others for interacting with your game or engine. 
- Clone or download the O2 Console repository or Unity package.
 - Import the console scripts into your Unity project.
 - Drag and drop the provided console prefab into your scene (includes input field & log display).
 - Optionally, set a hotkey (e.g., 
~) to toggle the console during play mode. 
To expose a command to the console, simply decorate methods, properties, or fields with the [ConsoleCommand("CommandKey")] attribute. The console will auto-register them.
[ConsoleCommand("GetValue")]
public int Value { get; set; }
[ConsoleCommand("GetStaticValue")]
public static int StaticValue { get; set; }
[ConsoleCommand("GetPrivateValue")]
private int PrivateValue;
[ConsoleCommand("InstanceMethod")]
public void InstanceMethod()
{
    // Your code here
}
[ConsoleCommand("SomeFunction")]
static string SomeFunction()
{
    return "Hello from static function!";
}.png)