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

[Released] Console Toolbox

Discussion in 'Assets and Asset Store' started by GrokGames, Oct 9, 2018.

  1. GrokGames

    GrokGames

    Joined:
    Oct 9, 2018
    Posts:
    6


    Console Toolbox is an all in one console and development tools suite. Simply drop the console into your existing project to start using its built in commands, then expand your toolbox with the click of a button!​

    Features:
    - Quake style console
    - TextMesh Pro GUI
    - New command editor/generator
    - Unity log/trace

    Built In Commands:
    - entity: suite of entity/scene hierarchy tools
    - scene: suite of scene management tools
    - help: describes all commands
    - log: toggle Unity log output
    - writelogs: write all console output to file

    Entity tools can output the current scene hierarchy to the console with optional entity filtering capabilities, allow you to call any function, check or modify a property value on an entity, and visually select entities.

    Scene tools provide a suite of commands to load and unload scenes (with options for additive and async), activate scenes, and list currently loaded scenes or available scenes.

    Also includes console variable capabilities and full source code!

    AssetStore | Website | Community Git

     
    Last edited: Oct 15, 2019
  2. AndreasO

    AndreasO

    Joined:
    Sep 25, 2012
    Posts:
    90
    Hey, logs with stacktraces would be helpful when exceptions are thrown.
     
    GrokGames and tgaldi like this.
  3. GrokGames

    GrokGames

    Joined:
    Oct 9, 2018
    Posts:
    6
    Hey Andreas0,

    Thanks for pointing that out - bit of an oversight on my part, I'm storing the trace in the logs but forgot to display them. Now that I'm looking into it I see that a trace level might also be useful, since all Unity debug callbacks are sent with a trace. I'll update this when I've submitted a solution to the asset store.

    Thanks again.
     
  4. AndreasO

    AndreasO

    Joined:
    Sep 25, 2012
    Posts:
    90
  5. GrokGames

    GrokGames

    Joined:
    Oct 9, 2018
    Posts:
    6
    Ok I've submitted version 1.1 to the asset store for all versions. Traces will display in the console and when writing the output to a log file. I've also replaced OutputStackTrace with OutputTraceLevel, which allows you to choose a trace level for unity output.

    Levels are:
    None: No stack traces
    Low: Only Exception and Assert traces
    Medium: Exception, Assert, and Error traces
    High: Exception, Assert, Error, and Warning traces
    All: Exception, Assert, Error, Warning, and Log traces

    More information can be found in the docs.
     
  6. GrokGames

    GrokGames

    Joined:
    Oct 9, 2018
    Posts:
    6
    Version 1.2 is available on the asset store.

    This version has been tested with the latest version of Unity (2019.2.9f1) and includes to following fixes:

    -fixed console output only displaying one item in builds
    -fixed cursor position when auto-completing commands
    -console now automatically adds an event system if not present
     
  7. jojo2K

    jojo2K

    Joined:
    Oct 6, 2018
    Posts:
    1
    Is it usable on mobile ? (virtual keyboard, and scroll on touch)
     
  8. GrokGames

    GrokGames

    Joined:
    Oct 9, 2018
    Posts:
    6
    @jojo2K I have not developed any mobile apps but according to Unity's documentation https://docs.unity3d.com/Manual/MobileKeyboard.html it should appear and work correctly when interacting with the terminal, which uses TextMeshPro InputField.

    Scrolling is handled with pageUp/pageDown.
     
  9. Xavier78

    Xavier78

    Joined:
    Oct 13, 2013
    Posts:
    40
    I am getting an error about the new unity input system. Is this compatible?
     
  10. Xavier78

    Xavier78

    Joined:
    Oct 13, 2013
    Posts:
    40
    I think I might have fixed it by replacing all the Input and KeyCodes with the new input system in the Terminal.cs and Console.cs. I haven't tested it fully, and for some reason in Console.cs to Terminal.cs the toggleFullModifier value changes, but other wise it seems to be working great.

    A good adition would be to add #if USE_NEW_INPUT to the code
     
  11. GrokGamingStudio

    GrokGamingStudio

    Joined:
    Aug 10, 2021
    Posts:
    3
    Hey there,

    Sorry about that, I haven't had the chance to update this asset now that the new input system is official. The easy way to use it would be to enable both the old and new systems:

    Edit->Project Settings->Player->Other Settings->Active Input Handling->Both


    Otherwise, you'll need to update Console.cs and Terminal.cs with the following, as well as reassigning the hotkeys in the prefab:

    Code (CSharp):
    1. #if ENABLE_INPUT_SYSTEM
    2. using UnityEngine.InputSystem;
    3. #endif
    4.  
    5.         [Header("Hotkeys")]
    6. #if ENABLE_INPUT_SYSTEM
    7.         [SerializeField]
    8.         public Key ToggleHotkey = Key.Backquote;
    9.         [SerializeField]
    10.         private Key ToggleFullModifier = Key.LeftShift;
    11.         [SerializeField]
    12.         private Key ToggleFullHotkey = Key.Backquote;
    13. #else
    14.         [SerializeField]
    15.         public KeyCode ToggleHotkey = KeyCode.BackQuote;
    16.         [SerializeField]
    17.         private KeyCode ToggleFullModifier = KeyCode.LeftShift;
    18.         [SerializeField]
    19.         private KeyCode ToggleFullHotkey = KeyCode.BackQuote;
    20. #endif
    21.  
    22.         protected override void Awake()
    23.         {
    24.             base.Awake();
    25.  
    26.             if( Console.Exists() )
    27.             {
    28. #if ENABLE_INPUT_SYSTEM
    29.                 Assert.AreNotEqual( ToggleHotkey, Key.Enter, "Return is not a valid ToggleHotkey" );
    30.                 Assert.AreNotEqual( ToggleHotkey, Key.Escape, "Escape is not a valid ToggleHotkey" );
    31.                 Assert.AreNotEqual( ToggleHotkey, Key.Tab, "Tab is not a valid ToggleHotkey" );
    32. #else
    33.                 Assert.AreNotEqual( ToggleHotkey, KeyCode.Return, "Return is not a valid ToggleHotkey" );
    34.                 Assert.AreNotEqual( ToggleHotkey, KeyCode.Escape, "Escape is not a valid ToggleHotkey" );
    35.                 Assert.AreNotEqual( ToggleHotkey, KeyCode.Tab, "Tab is not a valid ToggleHotkey" );
    36. #endif
    37.             }
    38.         }
    39.  

    Code (CSharp):
    1.      
    2. #if ENABLE_INPUT_SYSTEM
    3. using UnityEngine.InputSystem;
    4. #endif
    5.  
    6. #if ENABLE_INPUT_SYSTEM
    7.         public Key toggleHotkey { get; set; }
    8.         public Key toggleFullHotkey { get; set; }
    9.         public Key toggleFullModifier { get; set; }
    10. #else
    11.         public KeyCode toggleHotkey { get; set; }
    12.         public KeyCode toggleFullHotkey { get; set; }
    13.         public KeyCode toggleFullModifier { get; set; }
    14. #endif
    15.  
    16.  private void LateUpdate()
    17.         {
    18. #if ENABLE_INPUT_SYSTEM
    19.             var keyboard = Keyboard.current;
    20.  
    21.             if( keyboard[toggleFullModifier].isPressed &&
    22.                 keyboard[toggleFullHotkey].wasPressedThisFrame )
    23.             {
    24.                 if( GUI.activeSelf == false )
    25.                     return;
    26.  
    27.                 SetState( TerminalState.OpenLarge );
    28.  
    29.                 return;
    30.             }
    31.  
    32.             if( keyboard[Key.PageDown].isPressed )
    33.             {
    34.                 GUIScrollView.verticalNormalizedPosition -= ScrollSpeed;
    35.  
    36.                 return;
    37.             }
    38.  
    39.             if( keyboard[Key.PageUp].isPressed )
    40.             {
    41.                 GUIScrollView.verticalNormalizedPosition += ScrollSpeed;
    42.  
    43.                 return;
    44.             }
    45.  
    46.             if( keyboard.anyKey.wasPressedThisFrame == false )
    47.                 return;
    48.  
    49.             if( keyboard[toggleHotkey].wasPressedThisFrame )
    50.             {
    51.                 if( GUI.activeSelf == false )
    52.                 {
    53.                     GUI.SetActive( true );
    54.  
    55.                     onTerminalOpened.Invoke();
    56.                 }
    57.  
    58.                 SetState( TerminalState.OpenSmall );
    59.  
    60.                 return;
    61.             }
    62.  
    63.             if( keyboard[Key.Tab].wasPressedThisFrame )
    64.             {
    65.                 CompleteCommand();
    66.  
    67.                 return;
    68.             }
    69.  
    70.             if( keyboard[toggleHotkey].wasPressedThisFrame )
    71.             {
    72.                 SetState( TerminalState.OpenSmall );
    73.  
    74.                 return;
    75.             }
    76.  
    77.             if( keyboard[Key.UpArrow].wasPressedThisFrame )
    78.             {
    79.                 GUIInput.text = History.Previous();
    80.  
    81.                 GUIInput.MoveTextEnd( false );
    82.  
    83.                 return;
    84.             }
    85.  
    86.             if( keyboard[Key.DownArrow].wasPressedThisFrame )
    87.             {
    88.                 GUIInput.text = History.Next();
    89.  
    90.                 GUIInput.MoveTextEnd( false );
    91.  
    92.                 return;
    93.             }
    94.  
    95.             if( GUI.activeSelf == true )
    96.                 GUIInput.ActivateInputField();
    97.  
    98. #else
    99.             if( Input.GetKey( toggleFullModifier ) && Input.GetKeyDown( toggleFullHotkey ) )
    100.             {
    101.                 if( GUI.activeSelf == false )
    102.                     return;
    103.  
    104.                 SetState( TerminalState.OpenLarge );
    105.  
    106.                 return;
    107.             }
    108.  
    109.             if( Input.GetKey( KeyCode.PageDown ) )
    110.             {
    111.                 GUIScrollView.verticalNormalizedPosition -= ScrollSpeed;
    112.  
    113.                 return;
    114.             }
    115.  
    116.             if( Input.GetKey( KeyCode.PageUp ) )
    117.             {
    118.                 GUIScrollView.verticalNormalizedPosition += ScrollSpeed;
    119.  
    120.                 return;
    121.             }
    122.  
    123.             if( Input.anyKeyDown == false )
    124.                 return;
    125.  
    126.             if( Input.GetKeyDown( toggleHotkey ) )
    127.             {
    128.                 if( GUI.activeSelf == false )
    129.                 {
    130.                     GUI.SetActive( true );
    131.  
    132.                     onTerminalOpened.Invoke();
    133.                 }
    134.  
    135.                 SetState( TerminalState.OpenSmall );
    136.  
    137.                 return;
    138.             }
    139.  
    140.             if( Input.GetKeyDown( KeyCode.Tab ) )
    141.             {
    142.                 CompleteCommand();
    143.  
    144.                 return;
    145.             }
    146.  
    147.             if( Input.GetKeyDown( toggleHotkey ) )
    148.             {
    149.                 SetState( TerminalState.OpenSmall );
    150.  
    151.                 return;
    152.             }
    153.  
    154.             if( Input.GetKeyDown( KeyCode.UpArrow ) )
    155.             {
    156.                 GUIInput.text = History.Previous();
    157.  
    158.                 GUIInput.MoveTextEnd( false );
    159.  
    160.                 return;
    161.             }
    162.  
    163.             if( Input.GetKeyDown( KeyCode.DownArrow ) )
    164.             {
    165.                 GUIInput.text = History.Next();
    166.  
    167.                 GUIInput.MoveTextEnd( false );
    168.  
    169.                 return;
    170.             }
    171.  
    172.             if( GUI.activeSelf == true )
    173.                 GUIInput.ActivateInputField();
    174. #endif
    175.      }
    176.  
     
  12. GrokGamingStudio

    GrokGamingStudio

    Joined:
    Aug 10, 2021
    Posts:
    3
    An updated version has been published to the asset store that works with the new input system.