Search Unity

In-game Debug Console [Open Source]

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

  1. OverGast

    OverGast

    Joined:
    Aug 8, 2015
    Posts:
    30
    Hi! Just got your asset, amazing. It made my testing Android already easier and even more with the time.
    I just wondering if there is any way to know from where a log is coming. i.e. in the editor if you press on the log message you get a path from which script it has been called and what path it followed to get there.
    Is there anything similar in the ingame one? As imagine an error popups, how will you know which part of your code is getting that error (my case is only happening in the Android built, not reproducible on editor)?

    Apart from this, nice asset, thanks!
     
  2. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Unity doesn't provide log stacktraces in release builds, probably for performance reasons. If you enable Development Build in Build Settings, stacktraces should appear in the build, as well.
     
  3. Jh2556

    Jh2556

    Joined:
    Sep 29, 2014
    Posts:
    18
    @yasirkula Thanks for this plugin. It's one of my favorites, it's helped solve some tough issues in some builds!

    I'm using it for a project now, and we registered a few commands using the
    DebugLogConsole.AddCommand( string command, string description, System.Action method )
    but they don't show up when we use the "help" command. Are those entries something we need add manually?

    Secondly, we wanted to add a few overloaded versions of a command. So something like
    listscenes
    that takes no parameter, and
    listscenes string
    that takes a string as filter parameter so we can narrow down the scene name.

    It looks like currently when you add an overloaded parameter it only recognizes one of the methods it's calling. We could work around it by using a string parameter and doing some in method parsing. But it would simplify things if we had the ability to use overloaded methods. Is this something you could advise on?

    Thank you!!
     
  4. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @Jh2556 AddCommand should list the command in "help" list, unless a command with the same "command" parameter was already registered or there was an error registering the command.

    Supporting command overloads sounds useful. I've added it to my to-do list.
     
  5. Jh2556

    Jh2556

    Joined:
    Sep 29, 2014
    Posts:
    18
    Ok! Great to hear on the overloaded commands.

    @yasirkula Here's a snippet that shows where I'm adding the commands to the help list. The commands can be invoked fine, but they're not showing up in the help list. Any thoughts?

    Code (CSharp):
    1.         DebugLogConsole.AddCommand("printscenes", "print a list of all scenes by their build indexes and their names", PrintOutSceneList);
    2.     }
    3.  
    4.  
    5.     public void PrintOutSceneList()
    6.     {
    7.         PrintOutSceneList("");
    8.     }
     
  6. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Currently, after typing help, you need to click the "Available commands:" log to expand it. Perhaps you forgot to click it?
     
  7. Jh2556

    Jh2556

    Joined:
    Sep 29, 2014
    Posts:
    18


    Welp... I feel absolutely daft haha.

    Thank you!!
     
  8. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I've pushed an update to the GitHub repository for the 'help' issue. I've also added support for command overloads and will push it in the next update that will also bring enum and array support to the console. I haven't updated the unitypackage on GitHub yet, so you'll have to either download the repository as zip or wait for the unitypackage release.
     
  9. UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    Joined:
    Jan 9, 2017
    Posts:
    152
    @yasirkula Hi, I have a question but might not be directly related to the asset but I guess you might know best as you have experience in this. So I'm using your IngameDebugConsole on my android and I encounter this issue:

    Code (CSharp):
    1. AndroidJNIHelper.GetSignature: using Byte parameters is obsolete, use SByte parameters instead
    2. UnityEngine.AndroidJavaObject:Call(String, Object[])
    3. GooglePlayGames.Android.AndroidSavedGameClient:ReadBinaryData(ISavedGameMetadata, Action`2) (at F:/Desktop/Shark Pew Pew/SharkPewPew/Assets/GooglePlayGames/Platforms/Android/AndroidSavedGameClient.cs:210)
    4. EasyMobile.Internal.GameServices.AndroidSavedGameClient:ReadSavedGameData(SavedGame, Action`3) (at F:/Desktop/Shark Pew Pew/SharkPewPew/Assets/EasyMobile/Scripts/Modules/GameServices/SavedGames/Platforms/AndroidSavedGameClient.cs:95)
    5. CloudGameSave:ReadSavedGame(SavedGame, String) (at F:/Desktop/Shark Pew Pew/SharkPewPew/Assets/Scripts/Game Data Classes/CloudGameSave.cs:131)
    6. <PullDataFromCloud>d__5:MoveNext() (at F:/Desktop/Shark Pew Pew/SharkPewPew/Assets/Scripts/Game Data Classes/CloudGameSave.cs:72)
    7. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)
    I'm doing cloud saving using a third party asset. The author says this warning has no issues to the build and it's just a warning from the Google side. Which means only Google can remove this warning.

    So my question is, can I selectively delete a particular log message (eg: the one above) from the console, maybe by comparing string? Because I'm doing many cloud saving operations and this error happens twice per save.
    So 10 saves = 10 normal logs + 20 warning logs
     
  10. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Well, you can tell Unity to not log anything for a while but 1) it's an ugly workaround and 2) to omit only the selected logs, you must make the workaround even more uglier (I won't help with that step).

    To stop the logs for a while, you can follow this approach: https://github.com/yasirkula/UnityI...ectPlus/Editor/InspectPlusWindow.cs#L850-L874. Here, you can replace "
    assetImporterEditor = Editor.CreateEditor( assetImporter );
    " with your save function. Be aware that if an important error is logged to the console by that save function, you'll not be able to see it.

    I'd highly recommend you to consider modifying the plugin's source code so that it uses sbyte instead. If it is not possible, ignoring the warning might be the best solution.
     
  11. UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    Joined:
    Jan 9, 2017
    Posts:
    152
    Ok, I understand. I'm also afraid of not logging important messages with the first method. So I think I'll try meddling with the source code itself. But thank you for your time to share the method as a possible option.

    Side question, will you update the asset with filters? Meaning currently there are Normal/Warning/Error logs. If I for example do something like #Wallet# Wallet was opened. then a new tab (or filter) of Wallet will now be created alongside Normal/Warning/Error.

    Why I'm asking is because I'm using an enhanced console asset in my editor and it would be nice seeing that on my android too.
     
  12. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    For the time being, I'm not planning to add this feature. But in the future I might. Thanks for the suggestion!
     
  13. UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    Joined:
    Jan 9, 2017
    Posts:
    152
    Alright, no problem!
     
  14. biosmanager

    biosmanager

    Joined:
    May 10, 2017
    Posts:
    9
    First of all, great plugin!

    I'm using it in a VR project, how can I get rid of this warning:
    A Canvas named "IngameDebugConsole" with a render mode of ScreenSpaceOverlay is being used while VR is also enabled. This Canvas will continue to incur a rendering cost, but will not be visible while in VR. Is this intentional?


    I only need the debug console on the desktop screen.
     
  15. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You can destroy the IngameDebugConsole object in Awake when VR mode is activated. If the warning still shows up, you must either ignore the warning or instantiate IngameDebugConsole at runtime only when VR mode is disabled.
     
  16. biosmanager

    biosmanager

    Joined:
    May 10, 2017
    Posts:
    9
    The thing is, I want it on my desktop screen to see if something goes wrong. But I still need VR enabled.
     
  17. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I have no VR experience so I can't tell if it is possible to show a UI object only in the desktop screen. If IngameDebugConsole prefab can be seen on your desktop screen despite this warning, I think you can simply ignore the warning.
     
  18. rasto61

    rasto61

    Joined:
    Nov 1, 2015
    Posts:
    352
    @yasirakula Hi, would it be possible to add on show and on hide events to the console?
    Something like public event Action OnShowWindow, OnHideWindow; and fire them in Show/HideLogWindow?
     
  19. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    IARI and rasto61 like this.
  20. UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    Joined:
    Jan 9, 2017
    Posts:
    152
    Hello again @yasirkula! Any clue what this issue is?
    Code (CSharp):
    1. ArgumentOutOfRangeException: Index and length must refer to a location within the string.
    2. Parameter name: length
    3. System.String.Substring (System.Int32 startIndex, System.Int32 length) (at <00000000000000000000000000000000>:0)
    4. IngameDebugConsole.DebugLogItem.TitleContainsString (System.String title, System.String value) (at <00000000000000000000000000000000>:0)
    5. IngameDebugConsole.DebugLogItem.SetContent (IngameDebugConsole.DebugLogEntry logEntry, System.Int32 entryIndex, System.Boolean isExpanded) (at <00000000000000000000000000000000>:0)
    6. IngameDebugConsole.DebugLogRecycledListView.UpdateLogItemContentsBetweenIndices (System.Int32 topIndex, System.Int32 bottomIndex) (at <00000000000000000000000000000000>:0)
    7. UnityEngine.Events.UnityAction`1[T0].Invoke (T0 arg0) (at <00000000000000000000000000000000>:0)
    8. UnityEngine.Events.UnityEvent`1[T0].Invoke (T0 arg0) (at <00000000000000000000000000000000>:0)
    9. UnityEngine.UI.ScrollRect.LateUpdate () (at <00000000000000000000000000000000>:0)
    10.  
     
  21. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I can't find the TitleContainsString function in DebugLogItem script. Did you add it yourself or is your plugin not up-to-date?
     
  22. ShervinM

    ShervinM

    Joined:
    Sep 16, 2017
    Posts:
    67
    Fantastic asset! Thanks so much. Just a few questions if you dont mind!

    1. It seems like the bit of code that registers (adds) each console command specified via the attribute, is wrapped inside a UNITY_EDITOR define. Does that mean we can't have custom commands in builds?

    2. Any plans to add parameter suggestions as a feature? ideally we could specify a method (that returns a string array) to provide the suggestions. This could work via another attribute to specify which console command and what parameter index it provides them for.

    Thanks again!
     
  23. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You can add custom commands in builds. I can't remember which UNITY_EDITOR section you are mentioning but I can say that it doesn't restrict the commands to Editor.

    I don't have any plans for the second feature. There has been a pull request for this before that you may find useful.
     
  24. NemesisWarlock

    NemesisWarlock

    Joined:
    Jan 21, 2017
    Posts:
    141
    Bringing back the VR stuff from before, how can I display this in Worldspace?
     
  25. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You can simply set IngameDebugConsole canvas' Render Mode to World Space. Then reposition and scale the canvas if needed.
     
  26. Deleted User

    Deleted User

    Guest

    Hello yasirkula. I am using the new Input System, which is giving errors because older input APIs are being used internally. Is there any workaround at this point for the issue?
     
  27. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  28. VirtualMaestro

    VirtualMaestro

    Joined:
    Jul 2, 2014
    Posts:
    22
    Thank you for the asset!
    Would be great to see the New Input System support.
     
  29. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  30. Waz

    Waz

    Joined:
    May 1, 2010
    Posts:
    287
    Great asset. Just for fun I added a "print" function that prints the value of arbitrary component properties. I couldn't see any way for custom parsers or commands to implement their own completions though (which would actually make such a print function usable). It was also a bit awkward trying to cram the "documentation" into the description:

    Code (CSharp):
    1. DebugLogConsole.AddCommandStatic("print", "Print an object field or property: print Path/To/Object.Component.Member", "Print", GetType());
    2.  
     
  31. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Yeah, I guess not being able to customize the field names' appearance in help text can have negative impact in rare cases like this. Perhaps we can add an optional array parameter at the end to customize the field names.
     
  32. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @Waz With the latest release, you can call
    DebugLogConsole.AddCommandStatic("print", "Print an object field or property", "Print", GetType(), "Path/To/Object.Component.Member");
    . Auto-complete for parameters is still not a thing.
     
  33. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @nikhilsood_7 @VirtualMaestro It has been a couple of months but I've finally added support for new Input System. It requires a couple of manual modifications (see documentation) but they should take no longer than a minute.
     
  34. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    does this work on windows builds or only android? you should explicitly say what it works with if you can :) looks great
     
  35. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    It is supposed to work on every platform so I didn't think it was necessary to mention it explicitly.
     
    radiantboy likes this.
  36. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    yes and it does, its awesome!
     
    yasirkula likes this.
  37. dlevy_StatusPro

    dlevy_StatusPro

    Joined:
    Nov 8, 2020
    Posts:
    4
    Hello @yasirkula . I just installed you plugin and I am having a problem.
    After adding the prefab to my scene, I got a lot of warnings about :
    "There are 2  event systems in the scene. Please ensure there is always exactly one event system in the scene"

    I already had an EventSystem script in my scene so adding your plugin prefab caused this problem.
    I followed the documentation to upgrade to the new Unity input system and see where you indicate that I can disable the EventSystem child of the InGameDebugConsole prefab if I already have EventSystem in my scene. I disabled the EventSystem child and it resolves the warnings, but your Popup does not respond to input without this. If I enable EventSystem in InGameDebugConsole, the Popup works and I can move it around the screen and double click to see log details, but I am flooded with Warnings about 2 EventSystems. Any suggestions on how to resolve this?
     
  38. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You should follow the Input system instructions only if you're already using the new Input system. If you were using the legacy input system, don't switch to the new input system just for this plugin.

    To resolve the warning, you can delete the EventSystem child object of IngameDebugConsole prefab. If you were deactivating it at runtime, it could've caused the non-responsive popup issue.
     
    pitchblende likes this.
  39. dlevy_StatusPro

    dlevy_StatusPro

    Joined:
    Nov 8, 2020
    Posts:
    4
    upload_2021-7-26_10-52-16.png

    Sorry, I got it working. I just needed to add the Input System components from your EventSystem in the prefab to my EventSystem gameobject. I was using Oculus VR input before so I didnt have any Keyboard/Mouse input
    upload_2021-7-26_10-52-38.png
     
    yasirkula likes this.
  40. PanicMedia

    PanicMedia

    Joined:
    Dec 6, 2020
    Posts:
    37
    Hi, I am currently working on a game and I was wondering if anyone knew how to add commands?
     
  41. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  42. yarilo

    yarilo

    Joined:
    Dec 14, 2012
    Posts:
    5
    When I enter some text it shows some suggestion. For example I start to type "scene" and I see "scene.load" suggestion but when I click on suggestion nothing happens. Is this intentional behaviour or something doesn't work well?

    Another question - I can't find how to make it full screen. It takes only half of the screen

    Thank you
     
  43. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    1) This is the expected behaviour right now, you can't click on the suggestions.
    2) For initial fullscreen, select IngameDebugConsole/DebugLogWindow/RectTransform and set its Anchor Min and Bottom values to 0.
     
  44. IARI

    IARI

    Joined:
    May 8, 2014
    Posts:
    70
    This asset is amazing, thanks a lot! :)

    One question: to declutter the output of the help command is it possible to remove some of the commands provided by Default?
    for example, we have a custom mechanism to load scenes (actually AssetBundles) so laoding scenes doesn'T make a lot of sense.
    Without success I tried things like:
    Code (CSharp):
    1. DebugLogConsole.RemoveCommand("scene");
    2. DebugLogConsole.RemoveCommand("scene.load");
    3. DebugLogConsole.RemoveCommand("scene.restart");
     
  45. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Those lines worked for me. I've even called them in Awake :D Only scene.unload and scene.loadasync remained which weren't passed as parameter to RemoveCommand. You can also delete unwanted commands from "Plugins/IngameDebugConsole/Scripts/Commands", if you wish.
     
    IARI likes this.
  46. IARI

    IARI

    Joined:
    May 8, 2014
    Posts:
    70
    Installed from UPM since I don't want to not have the copde in the git-repo - so rather no deleting upstream files ^^
    But yeah - I wonder why the lines didn't work for me - I called them in a static constructor. then tried to call them in a staticconstructor with a delay of 1.5 secondes - in both cases, the commands remained.

    Probably it wasnt executed - maybe i should try [InitializeOnLoadMethod] or [RuntimeInitializeOnLoadMethod]

    Edit: yep, my silly mistake - it works! :)
     
    Last edited: Dec 7, 2021
    yasirkula likes this.
  47. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  48. K0ST4S

    K0ST4S

    Joined:
    Feb 2, 2017
    Posts:
    35
    I had all my debug commands removed in builds because of `Managed Stripping Level` set to High. Hope someone helps. Cheers.
     
  49. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You can add [UnityEngine.Scripting.Preserve] attribute to your methods.
     
    K0ST4S likes this.
  50. Romaleks360

    Romaleks360

    Joined:
    Sep 9, 2017
    Posts:
    72
    As I understand it, the console is not very useful in any kind of production build at the moment because it doesn't collect logs when disabled. Keeping it enabled is a no-go - even when canvas is disabled, it still runs a pretty heavy code in LateUpdate, and that's just a useless waste of resources for most of the players.
    Console should have some kind of an eco-mode when disabled - simply collecting string logs and adding them to pending queue, nothing more. Process them only when enabled.
    The most common use case of any console is opening it after an error happened to see what went wrong. Before that, it should be as invisible as possible.