Skip to content

o2 Console is an in-game, attribute-driven debug console for Unity that allows developers to define and execute commands easily. Built using the Reflection API, it dynamically discovers scene objects and registers command methods at runtime, making it incredibly flexible.

License

Notifications You must be signed in to change notification settings

OxygenButBeta/O2-InGame-Console-For-Unity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

21 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ O2 InGame Console

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.


โœจ Features

  • ๐Ÿท๏ธ 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 /Clear to clear logs and others for interacting with your game or engine.


๐ŸŽจ User Interface

O2 Console Screenshot

๐Ÿš€ Getting Started

Installation

  1. Clone or download the O2 Console repository or Unity package.
  2. Import the console scripts into your Unity project.
  3. Drag and drop the provided console prefab into your scene (includes input field & log display).
  4. Optionally, set a hotkey (e.g., ~) to toggle the console during play mode.

Usage

To expose a command to the console, simply decorate methods, properties, or fields with the [ConsoleCommand("CommandKey")] attribute. The console will auto-register them.

Example: Properties & Fields

[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!";
}

About

o2 Console is an in-game, attribute-driven debug console for Unity that allows developers to define and execute commands easily. Built using the Reflection API, it dynamically discovers scene objects and registers command methods at runtime, making it incredibly flexible.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages