Search Unity

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:
    2,879
    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://assetstore.unity.com/packages/tools/gui/in-game-debug-console-68068
    Also available at: https://github.com/yasirkula/UnityIngameDebugConsole
    Discord: https://discord.gg/UJJt549AaV
    GitHub Sponsors ☕

    1.png

    2.png

    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.

    3.png

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

    FAQ
    • "Receive Logcat Logs In Android" isn't working, it says "java.lang.ClassNotFoundException: com.yasirkula.unity.DebugConsoleLogcatLogger" in Logcat
    If you are sure that your plugin is up-to-date, then enable Custom Proguard File option from Player Settings and add the following line to that file:
    -keep class com.yasirkula.unity.* { *; }


    Enjoy!
     
    Last edited: May 31, 2023
    Bushy_Zerg, y01cu, pansoul and 5 others like this.
  2. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    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!
     
    AlexTinyRebel and EvOne like this.
  3. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    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
     
    mawika likes this.
  4. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,664
    That's awesome!
     
  5. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    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:
    1,642
    looks great.
     
    yasirkula likes this.
  7. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    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:
    1,642
    you were able to redirect native unity logs? How did you do it?
     
  9. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  10. sebas77

    sebas77

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

    yasirkula

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

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  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:
    2,879
    AFAIK, it is only possible if you build in Development Mode.
     
    UNSEENWorks and echoMike like this.
  15. CrystalConflux

    CrystalConflux

    Joined:
    May 25, 2017
    Posts:
    107
    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:
    2
    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:
    2,879
    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:
    37
    Is it possible to make it hidden as default - and only appear when using the hotkey?
     
  23. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    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. UnusAutomationSystems

    UnusAutomationSystems

    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:
    2,879
    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:
    2,879
    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. }
     
  28. nekolyst

    nekolyst

    Joined:
    Mar 12, 2018
    Posts:
    23
    Hi, I got this error every frame in enter play mode if import In-game Debug Console asset:

    NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.Rendering.DebugManager.UpdateActions () (at Library/PackageCache/com.unity.render-pipelines.core@7.1.8/Runtime/Debugging/DebugManager.Actions.cs:165)
    UnityEngine.Rendering.DebugUpdater.Update () (at Library/PackageCache/com.unity.render-pipelines.core@7.1.8/Runtime/Debugging/DebugUpdater.cs:18)

    Unity version: 2019.3.0f6
     
  29. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I couldn't reproduce this issue on my URP installed 2019.3.0f6 project. Honestly, I don't know how a URP script inside Packages would be affected by my plugin inside Assets.
     
  30. nekolyst

    nekolyst

    Joined:
    Mar 12, 2018
    Posts:
    23
    I got the same error after import the Unity Recorder asset.
    Remove and reinstall the URP package can resolve this problem.

    So it seems to be caused by URP, not your asset.
    Thanks for your fast reply.
     
    yasirkula likes this.
  31. UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    Joined:
    Jan 9, 2017
    Posts:
    152
    This package is really awesome goodness! Can I check if I can filter (or search) to show results of my choice? For example I will have "[network] Some comments" and "[saving system] Some comments" and I would like to see logs of only [network].
     
    ScottAdams likes this.
  32. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    There is no search functionality at the moment but I agree that it can be useful. Added to my to-do list.
     
  33. UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    Joined:
    Jan 9, 2017
    Posts:
    152
    No worries man! I was only asking if there was. The package is already really really awesomely amazing! No need to trouble yourself :)
     
  34. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Updated the plugin on GitHub. In addition to the searchbar, I've also added a Copy button to the expanded logs.
     
  35. UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    Joined:
    Jan 9, 2017
    Posts:
    152
    You didn't have to! Thank you so much :) I'll download it soon.
     
  36. cibaben5

    cibaben5

    Joined:
    Mar 12, 2020
    Posts:
    6
    Hello ! first I would like to thank you for this file browser could you help me to integrate it into my project or else you have a tutorial to show this, please it's important
     
  37. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  38. cibaben5

    cibaben5

    Joined:
    Mar 12, 2020
    Posts:
    6
    upload_2020-4-11_15-31-43.png
    j'ai compris when i try it !
     

    Attached Files:

  39. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  40. cibaben5

    cibaben5

    Joined:
    Mar 12, 2020
    Posts:
    6
    [QUOTE = "yasirkula, message: 5699035, membre: 56169"] Vous appelez ShowSaveDialog / ShowLoadDialog alors qu'une autre boîte de dialogue est toujours visible. SimpleFileBrowser a son propre fil de discussion dédié, si vous souhaitez poser une autre question: https://forum.unity.com/threads/simple-file-browser-open-source.441908/ [/ QUOTE]
    ok thanks :)
     
  41. ScottAdams

    ScottAdams

    Joined:
    Nov 23, 2016
    Posts:
    72
    I used the save log function ingame in debug console and it replied it was saving them to a directory and file.

    I am unable to find where this directory is stored. Running on Windows with desktop build, editor build and a WebGL build. How can I locate the log files or tell debug console where i want them stored?

    Again thanks for a wonderful app it has been extremely useful.

    Scott Adams
    www.Clopas.net
     
  42. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    ScottAdams likes this.
  43. ScottAdams

    ScottAdams

    Joined:
    Nov 23, 2016
    Posts:
    72
    Thanks that was exactly what was needed!
     
    yasirkula likes this.
  44. UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    Joined:
    Jan 9, 2017
    Posts:
    152
    @yasirkula, may I check with you. This might sound a little silly... I'll list my questions in point forms.
    1. On production build, should I remove the debug console from the scene completely or can I just leave it disabled?
    2. Does leaving it disabled cause any performance hit, consume draw calls, etc?
    3. I know removing it is the right choice. But I'm thinking of adding a hidden button in the game so that I can enable the debug console and see what is going on if my family/friends are encountering some issues. Will the debug console catch log messages when it is disabled?
     
  45. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    1. Both options are fine but if you aren't planning to use the console, you can remove it from the scene so that it can be stripped from the build.
    2. Should have no performance impact.
    3. It won't catch log messages when the IngameDebugConsole object is inactive. What you want is possible but be aware that IngameDebugConsole will have to use some CPU to process the incoming logs. To achieve this, you can set the IngameDebugConsole object's "Enable Popup" to false and "Start Minimized" to true. Then, you can call
    FindObjectOfType<IngameDebugConsole.DebugLogManager>().ShowLogWindow()
    when the hidden button is clicked to show the debug console. You should leave the IngameDebugConsole object active for this to work.
     
  46. UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    Joined:
    Jan 9, 2017
    Posts:
    152
    Thank you! It works great :)
     
    yasirkula likes this.
  47. kloot

    kloot

    Joined:
    Mar 14, 2018
    Posts:
    78
    Really neat plugin!

    Suggestion: I would love to have a "Mail" button that opens up a mail draft using the mailto url scheme, ideally attaching the whole log content for the mail body.

    Also, is there an easy way of blocking the clicks from triggering whatever is drawn underneath the console?

    Thanks a bunch!
     
    ScottAdams likes this.
  48. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Composing a new email with an attachment requires native libraries on mobile and I honestly don't know how it can be achieved on other platforms. I'm not planning to add built-in support for it but on mobile, you can use NativeShare to add this functionality. After importing the plugin, you can add the following line to DebugLogManager.SaveLogsToFile:
    new NativeShare().AddFile(path).Share();
    . Now, whenever you activate the save_logs command, the share dialog will automatically show up.

    You can call the
    EventSystem.current.IsPointerOverGameObject()
    function to check if the mouse/finger is on a UI element. If it is, you can ignore that touch.
     
  49. kloot

    kloot

    Joined:
    Mar 14, 2018
    Posts:
    78
  50. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    There is a character limit for mailto, so it is not a reliable solution.