Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Reactor - Open Source Developer Console

Discussion in 'Assets and Asset Store' started by pexnplayer, Sep 8, 2019.

  1. pexnplayer

    pexnplayer

    Joined:
    Sep 8, 2019
    Posts:
    3
    Reactor Console

    Debug your build, create your own commands easily.


    So I was working for my souls-like game and I came up with this tool. I thought sharing with community would be useful. Thus I made simple revisions and I added useful commands that I needed when I was debugging & developing a product.

    [Github]


    Implementing to your project

    1-Download the latest version and import to your project.
    2-Drag the "Developer Console" prefab to your scene.

    Defaultly `F4` is gonna open the console.



    Features
    • Lean and resizeable user interface
    • Powerful built-in commands
    • Simple and modular command system
    • Input predictions and hints
    • Output filter system
    • Input history system


    Anatomy



    You can filter output at upper left corner. You can resize the window with the drag at the lower right corner.


    It will draw predictions with your input. You can navigate on predictions with ` ↓ , ↑ ` keys. Submitted inputs can be restored later by pressing ` ↑ ` .

    Console Syntax

    Anatomy of provided input must be like this;

    `[command] [params]`

    Consider there are 2 invoke definitions `culture` & `culture [CultureInfo]`. The first one prints the current culture and the second one changes it. Input must be;



    Consider you need to move transform named Main Camera.



    You have to use brackets for combining words.





    Adding new commands
    Reactor console supports adding commands and parameters using attributes. There can be more than one invoke definitions for each command. Built-in commands are stored in `Commands.cs`.

    For adding a new command you have to create a new class inherits from `Console.Command` and attribute it with `ConsoleCommand` attribute.

    NOTE: Do not forget to make parameter field public

    Code (CSharp):
    1.     //Define command query identity, description and optionally for only developer version mode
    2.       [ConsoleCommand("culture", "Set the culture", true)]
    3.     class CultureSet : Command]//Inherits class from Console.Command
    4.         {
    5.             [CommandParameter("CultureInfo")] //Add parameter for command
    6.             public System.Globalization.CultureInfo value;
    7.          
    8.             public override ConsoleOutput Logic() //Virtual logic method for every command,
    9.             {
    10.                 base.Logic();
    11.                 var cultureInfo = value;//Command logic
    12.              
    13.         //Return console output with message, output type and optionally time signature
    14.                 return new ConsoleOutput("Culture is now "+ cultureInfo, ConsoleOutput.OutputType.Log, false);
    15.  
    16.             }
    17.         }
    In this example we have set the current culture to provided CultureInfo by user. But what if user wants to print the current culture instead of changing it? We should move on to another invoke definition.


    Code (CSharp):
    1.         //We've added the same command again, but now there is no parameter.
    2.         //Now user can type only "culture" to get culture information.
    3.         [ConsoleCommand("culture", "Get the culture")]
    4.         class CultureGet : Command
    5.         {
    6.             //No parameters
    7.             public override ConsoleOutput Logic()
    8.             {
    9.                 base.Logic();
    10.                 var oldCulture = System.Globalization.CultureInfo.CurrentCulture.Name;
    11.  
    12.                 return new ConsoleOutput("Culture is " + oldCulture, ConsoleOutput.OutputType.Log, false);
    13.  
    14.             }
    15.         }

    If there are two same invoke definitions(same query identity and same parameters) one of them will be ignored.

    Have a problem?
    Search in repo wiki, ask in forum or contact me.

    Please report issues here.
     

    Attached Files: