Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

In-game Debug Console [Open Source]

Discussion in 'Assets and Asset Store' started by yasirkula, Jun 15, 2016.

  1. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,169
    Hi there,

    I was recently working on an open-source in-game debug console for Unity to see debug messages in game (especially useful for mobile devices). Well, I have made some real progress and wanted to share the results with you. Hope you like it :)

    Asset Store: https://www.assetstore.unity3d.com/en/#!/content/68068
    Also available at: https://github.com/yasirkula/UnityIngameDebugConsole





    ABOUT

    This asset helps you see debug messages (logs, warnings, errors, exceptions) runtime in a build (also assertions in editor) and execute commands using its built-in console. It also supports logging logcat messages to the console on Android platform.

    User interface is created with uGUI and costs 1 SetPass call (and 6 to 10 batches). It is possible to resize or hide the console window during the game. Once the console is hidden, a small popup will take its place (which can be dragged around). Console window will reappear after clicking the popup.



    Console window is optimized using a customized recycled list view that calls Instantiate function sparingly.

    HOW TO

    Simply import IngameDebugConsole.unitypackage to your project and place IngameDebugConsole prefab to your scene. You may want to tweak the following settings:
    • Singleton: if enabled, console window will persist between scenes (recommended). If, however, you don't want the console on each scene, then deselect this option and manually drag & drop the DebugLogCanvas prefab to the scenes you want
    • Clear Command After Execution: if enabled, the command input field at the bottom of the console window will automatically be cleared after entering a command. If you want to spam a command, or make small tweaks to the previous command without having to write the whole command again, then deselect this option
    • Receive Logcat Logs In Android: if enabled, on Android platform, logcat entries of the application will also be logged to the console with the prefix "LOGCAT:". This may come in handy especially if you want to access the native logs of your Android plugins (like Admob)
    • Logcat Arguments: on Android, if Logcat logs are enabled, native logs will be filtered using these arguments. If left blank, all native logs of the application will be logged to the console. If you want to, for example, see Admob's logs only, you can enter -s Ads here
    More information available at the repository. Enjoy!
     
    Last edited: Mar 12, 2018
    irshadmpm and theANMATOR2b like this.
  2. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,169
    Package updated:
    • Performance has been improved considerably using a customized recycled list view
    • Added buttons to filter logs by their types
    • Added a popup that will take the console's place when the console is hidden (see the main post)
    And, again, it is completely free and open-source. Enjoy!
     
  3. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,169
    Update (25.08.2016):
    • Added commands: assign commands to your script functions and call them in-game using the console. Both static and instance methods are supported. Parameter types should match one of the following: int, float, bool, string, Vector2, Vector3 and/or Vector4
     
  4. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    1,597
    That's awesome!
     
  5. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,169
    Thank you :) I've also submitted the package to the asset store today (free, of course). Hopefully, it will be available there, too.
     
    theANMATOR2b and Mauri like this.
  6. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    922
    looks great.
     
    yasirkula likes this.
  7. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,169
    The asset is updated and now supports showing native logcat entries (for Unity activity only) as well.
     
  8. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    922
    you were able to redirect native unity logs? How did you do it?
     
  9. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,169
  10. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    922
    ohh so I guess it works only on android?
     
  11. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,169
    Yeah, I said logcat but I forgot to mention Android :)
     
  12. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,169
  13. echoMike

    echoMike

    Joined:
    Oct 24, 2017
    Posts:
    4
    Can StackTrace messges also be logged on Andorid? I can't find any option for this...
     
  14. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,169
    AFAIK, it is only possible if you build in Development Mode.
     
    echoMike likes this.
  15. CrystalConflux

    CrystalConflux

    Joined:
    May 25, 2017
    Posts:
    100
    Thanks for this. Just what I needed.
     
  16. echoMike

    echoMike

    Joined:
    Oct 24, 2017
    Posts:
    4
    Yeah I found out later that day. It does only work in Development Build...:p
     
  17. nischi

    nischi

    Joined:
    Mar 16, 2016
    Posts:
    1
    It works really fine.
    Thanks also for the info "save_logs".

    I did not recognice, that i have to click on the message to get the full help info.

    Thanks for you cool asset,

    Alex
     
    yasirkula likes this.
  18. Thyasianman

    Thyasianman

    Joined:
    May 24, 2016
    Posts:
    1
    Plug in is still working great! To anyone having trouble, don't use the prefab in the prefab folder, use the prefab in the main folder. I had a problem only in build, and this allowed me to find it. Thanks a lot!
     
  19. edsh

    edsh

    Joined:
    Mar 10, 2015
    Posts:
    1
    This plugin is awesome! I've just implemented it in an ARCore mobile app (android) using Unity version 2019.1.1f1

    Could'nt get it to log Debug.LogError messages directly when running the app on an actual device, but I get the logcat messages. Therefore I added some small code to the DebugLogManager to evaluate the correct logging level and make sure each log ends up in the correct log level tab.

    Thanks @yasirkula for creating this awesome tool!
     
    yasirkula likes this.
  20. VotrePseudo

    VotrePseudo

    Joined:
    Jun 17, 2019
    Posts:
    4
    Hi @yasirkula ,

    I have been working with your plugin for some time now and I encountered an issue: I create a TCP server and a TCP client and connect in asynchronous mode and then send a message from client to server and your console does not show the command
    Code (CSharp):
    1. Debug.Log("Received new message : " + message);
    but, when I run in editor, the debug.log shows.

    On the client side, it stops showing logs after I call
    Code (CSharp):
    1. NetworkStream stream = client.GetStream();
    2. stream.BeginWrite(buffer, 0, buffer.Length, EndSend, data);
    (the next debug.log is in the EndSend function)

    On the server side, it stops showing after I call
    Code (CSharp):
    1. server.BeginAcceptTcpClient(OnClientConnect, new object());
    (the next debug.log is in the OnClientConnect function)

    Would you know why the message is not showing?

    Otherwise, your plugin is great and really well done so thank you for it :)

    Thank you in advance for your answer
     
  21. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,169
    Debug console fetches logs from the
    Application.logMessageReceived
    event. You may check if
    Application.logMessageReceivedThreaded
    receives the logs that the other event doesn't catch but if the threaded variant also doesn't work, then I don't think I'll be able to resolve this issue.
     
  22. zt3ff3n

    zt3ff3n

    Joined:
    Feb 19, 2016
    Posts:
    17
    Is it possible to make it hidden as default - and only appear when using the hotkey?
     
  23. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,169
    Yes, simply adding
    ShowPopup();
    to the end of DebugLogManager.Start function should do the trick! There is no way to achieve this from the Inspector yet, sorry :)
     
  24. unussystems

    unussystems

    Joined:
    Jul 15, 2019
    Posts:
    49
    can we save all logs into file by using this asset?
     
  25. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,169
    Of course! In the input field of the console, type
    save_logs
    and it should save the logs to a file.
     
  26. Demise

    Demise

    Joined:
    Sep 8, 2019
    Posts:
    2
    Would it be possible for me to edit stats of my player with commands such as a command like /setgold 100 and it sets the gold of my player to 100 or /addgold 100 and it adds 100 gold?
     
  27. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,169
    Yes, you can add the following code to your player:

    Code (CSharp):
    1. private int golds;
    2.  
    3. void Start()
    4. {
    5.     IngameDebugConsole.DebugLogConsole.AddCommandInstance( "/addgold", "Increases gold", "AddGold", this );
    6. }
    7.  
    8. void OnDestroy()
    9. {
    10.     IngameDebugConsole.DebugLogConsole.RemoveCommand( "/addgold" );
    11. }
    12.  
    13. void AddGold( int delta )
    14. {
    15.     golds += delta;
    16. }