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
    I think I can put the code inside LateUpdate in an
    if(isLogWindowVisible || PopupEnabled)
    condition but I've noticed that log timestamps are captured inside ProcessLog, so I'll need to modify that first. I may also add a "Capture Logs When Inactive" boolean regardless of this change.

    EDIT: Added in v1.5.6.
     
    Last edited: May 7, 2022
  2. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    @yasirkula Awesome asset thank you for so generously sharing with the community.

    I'm struggling to find a way of setting a preset size and position for the console. I can resize as required (I have EnableHorizontalResizing enabled) but I would love to not have to do this every time I open the console.

    Currently it opens as full width at the top of the screen. I'd love to be able to set it to left of the screen, and ideally at a set height (just short of the full height)

    Is there an easy way of doing this?

    (I tried nesting the prefab in a parent canvas to contain it where I want it, but it broke the layout of the console)
     
  3. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Hi! I think you can resize the debug console to the desired size at runtime, copy its LogWindow's RectTransform and then paste the component to the instance in your scene after exiting play mode.
     
    jeromeWork likes this.
  4. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    I tried that :D but sadly it gets reset. I'm assuming there's some initialisation code. Thanks. I'll try to delve deeper into the code
     
  5. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I've copy&pasted DebugLogWindow's RectTransform before&after play mode and it worked well for me :)
     
    jeromeWork likes this.
  6. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    I take it all back. tried again and that worked just as you say. Sorry! :rolleyes: thanks for taking the time for the quick replies
     
    yasirkula likes this.
  7. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    Hi! Thanks for the plugin! Is there a way to make the popup show up only in Development Builds?
     
  8. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @bourriquet Hi! You can set DebugLogManager.Instance.PopupEnabled to false in release builds. PS. You'll need to do it with 1 frame delay because PopupEnabled is modified in DebugLogManager.Start.
     
  9. invoguedev1

    invoguedev1

    Joined:
    Jun 13, 2022
    Posts:
    1
    Hi @yasirkula really really thanks for the Plugin it's handy I always wanted that this kind of plugin is available
    but it not work with the latest input system
    I also read your new Input system Support but still this error occur overall its working fine
    upload_2022-8-24_19-12-39.png
     
  10. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @invoguedev1 All Input functions are wrapped inside
    #if !ENABLE_INPUT_SYSTEM || ENABLE_LEGACY_INPUT_MANAGER
    which should be compiled when either the legacy input manager is used or both input systems are used at the same time. At the moment, I don't understand why Unity would disregard these compiler directives :( Perhaps reinstalling the plugin (or if it's installed as package, installing it from Asset Store/GitHub) would resolve the issue.
     
  11. qtran122

    qtran122

    Joined:
    Dec 16, 2013
    Posts:
    6
    Hi @yasirkula, thanks for the wonderful tool. It's been extremely helpful to my dev process :)

    Recently, I encountered a weird bug that I think you might want to know about. I updated to the latest version, and that caused the debug console in the build to become unresponsive. This only affects the build. In the editor, it works same as usual.

    I recorded a video (link here). Not sure if it's a widely occurring issue or just relegated to my build. I'm able to work around it by switching back to the previous version.
     
  12. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @qtran122 Hi! I'm using the latest version in my mobile game (Unity 2021.3.6f1) without any issues at the moment. I am totally clueless why it stops working in your build :D Can you add an EventSystem to your scene and try again? Can you try it on a new Unity project's build, too?
     
  13. qtran122

    qtran122

    Joined:
    Dec 16, 2013
    Posts:
    6
    Hi @yasirkula, thanks for your advice! Turns out the problem did have to do with EventSystem. I found that when I updated, the event system would become deactivated. It would still be there, just in a deactivated state. This didn't cause any issues in the editor, but did in the build. But simply re-enabling it allowed me to use InDebugConsole in the build like normal again :D

    Sorry for the false alarm. Thanks for the help!
     
  14. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  15. Xelnath

    Xelnath

    Joined:
    Jan 31, 2015
    Posts:
    402
    This console is great, but I noticed it doesn't support default parameters. Is that feasible?
     
    yasirkula likes this.
  16. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    It's possible. I'll keep this feature request in mind.
     
    Xelnath likes this.
  17. mikeohc

    mikeohc

    Joined:
    Jul 1, 2020
    Posts:
    215
    Hi there, amazing plugin. The only thing is I'm getting spammed with
    SendMessage cannot be called during Awake, CheckConsistency, or OnValidate
    . I'm using additive scenes, and I think that's when the errors come in. Any new ui created in the additive scene gets spammed with the error above.
     
  18. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  19. mikeohc

    mikeohc

    Joined:
    Jul 1, 2020
    Posts:
    215
    Here's the full warning log for one of the log. I'm getting a lot of
    Code (CSharp):
    1. OnRectTransformDimensionsChange
    but for different UI components. I'm not sure where the issue might be, but searching for
    SendMessage cannot be called during Awake, CheckConsistency, or OnValidate
    on the unity forum, I came across this post. So maybe when additive scenes get loaded, UI is being created on Awake and it conflicts with the debugconsole somehow?
    Code (CSharp):
    1. SendMessage cannot be called during Awake, CheckConsistency, or OnValidate (Image: OnRectTransformDimensionsChange)
    2. 0x00007ff77ee9f9fd (Unity) StackWalker::GetCurrentCallstack
    3. 0x00007ff77eea66f9 (Unity) StackWalker::ShowCallstack
    4. 0x00007ff77fe41943 (Unity) GetStacktrace
    5. 0x00007ff7804f7ea3 (Unity) DebugStringToFile
    6. 0x00007ff77e73ad14 (Unity) GameObject::SendMessageAny
    7. 0x00007ff77ebdd026 (Unity) UI::RectTransform::UpdatePosAndRectRecursive
    8. 0x00007ff77ebdcfd2 (Unity) UI::RectTransform::UpdatePosAndRectRecursive
    9. 0x00007ff77de9b50a (Unity) RectTransform_CUSTOM_set_sizeDelta_Injected
    10. 0x0000020e21417c8c (Mono JIT Code) (wrapper managed-to-native) UnityEngine.RectTransform:set_sizeDelta_Injected (UnityEngine.RectTransform,UnityEngine.Vector2&)
    11. 0x0000020e21417bab (Mono JIT Code) UnityEngine.RectTransform:set_sizeDelta (UnityEngine.Vector2)
    12. 0x0000020e2141762b (Mono JIT Code) [LayoutGroup.cs:312] UnityEngine.UI.LayoutGroup:SetChildAlongAxisWithScale (UnityEngine.RectTransform,int,single,single,single)
    13. 0x0000020e21416b9b (Mono JIT Code) [HorizontalOrVerticalLayoutGroup.cs:209] UnityEngine.UI.HorizontalOrVerticalLayoutGroup:SetChildrenAlongAxis (int,bool)
    14. 0x0000020e214187a3 (Mono JIT Code) [HorizontalLayoutGroup.cs:35] UnityEngine.UI.HorizontalLayoutGroup:SetLayoutHorizontal ()
    15. 0x0000020e21415ab3 (Mono JIT Code) [LayoutRebuilder.cs:86] UnityEngine.UI.LayoutRebuilder/<>c:<Rebuild>b__12_1 (UnityEngine.Component)
    16. 0x0000020e214158e4 (Mono JIT Code) [LayoutRebuilder.cs:116] UnityEngine.UI.LayoutRebuilder:PerformLayoutControl (UnityEngine.RectTransform,UnityEngine.Events.UnityAction`1<UnityEngine.Component>)
    17. 0x0000020e21409b03 (Mono JIT Code) [LayoutRebuilder.cs:87] UnityEngine.UI.LayoutRebuilder:Rebuild (UnityEngine.UI.CanvasUpdate)
    18. 0x0000020e2140838d (Mono JIT Code) [CanvasUpdateRegistry.cs:182] UnityEngine.UI.CanvasUpdateRegistry:PerformUpdate ()
    19. 0x0000020e21408092 (Mono JIT Code) (wrapper delegate-invoke) <Module>:invoke_void ()
    20. 0x0000020e2140819c (Mono JIT Code) UnityEngine.Canvas:SendWillRenderCanvases ()
    21. 0x0000020e21407f2b (Mono JIT Code) UnityEngine.Canvas:ForceUpdateCanvases ()
    22. 0x0000020e21407acb (Mono JIT Code) [InputField.cs:2521] UnityEngine.UI.InputField:UpdateLabel ()
    23. 0x0000020df638577b (Mono JIT Code) [InputField.cs:1116] UnityEngine.UI.InputField:OnValidate ()
    24. 0x0000020f1a9f14d8 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    25. 0x00007ffc80aa0384 (mono-2.0-bdwgc) [mini-runtime.c:3445] mono_jit_runtime_invoke
    26. 0x00007ffc809deb34 (mono-2.0-bdwgc) [object.c:3066] do_runtime_invoke
    27. 0x00007ffc809deccc (mono-2.0-bdwgc) [object.c:3113] mono_runtime_invoke
    28. 0x00007ff77edc3f14 (Unity) scripting_method_invoke
    29. 0x00007ff77eda3864 (Unity) ScriptingInvocation::Invoke
    30. 0x00007ff77eda394e (Unity) ScriptingInvocation::InvokeChecked
    31. 0x00007ff77ee38d66 (Unity) SerializableManagedRef::CallMethod
    32. 0x00007ff77ed8c873 (Unity) MonoBehaviour::CheckConsistency
    33. 0x00007ff77ed8b0c3 (Unity) MonoBehaviour::AwakeAfterRestoreFromBackup
    34. 0x00007ff77ee3870a (Unity) SerializableManagedRefsUtilities::AwakeInstancesAfterBackupRestoration
    35. 0x00007ff77ed8e06d (Unity) MonoManager::EndReloadAssembly
    36. 0x00007ff77ed95d68 (Unity) MonoManager::ReloadAssembly
    37. 0x00007ff77fcf035d (Unity) Internal_ADB_Only_ReloadAllUsedAssemblies
    38. 0x00007ff7801ba656 (Unity) ImportOutOfDateAssets
    39. 0x00007ff7801c6553 (Unity) RefreshInternalV2
    40. 0x00007ff7801cddc5 (Unity) StopAssetImportingV2Internal
    41. 0x00007ff77fccd8a7 (Unity) EditorSceneManager::RestoreSceneBackups
    42. 0x00007ff77f9cda66 (Unity) PlayerLoopController::EnterPlayMode
    43. 0x00007ff77f9dd77a (Unity) PlayerLoopController::SetIsPlaying
    44. 0x00007ff77f9e0e80 (Unity) Application::TickTimer
    45. 0x00007ff77fe4759a (Unity) MainMessageLoop
    46. 0x00007ff77fe4c3b4 (Unity) WinMain
    47. 0x00007ff7811c448e (Unity) __scrt_common_main_seh
    48. 0x00007ffcebe57614 (KERNEL32) BaseThreadInitThunk
    49. 0x00007ffced2426a1 (ntdll) RtlUserThreadStart
    50.  
     
  20. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Thank you for the logs. At the moment I am unable to guess the cause of this issue or its connection to the plugin. I'd need to do a lot of trials and errors by commenting out sections of the code and seeing if the warnings go away but first I need to reproduce this issue. You just have a scene with debug console and loading it additively am I right? What is your Unity version?
     
  21. mikeohc

    mikeohc

    Joined:
    Jul 1, 2020
    Posts:
    215
    I'm on Unity 2022.1.23 HDRP. I have a persistent scene and when I load into the game, I load scenes additively. The reason why I suspect it's due to additive scenes is because these warnings show up when any additive scenes has an UI component.

    I opened my project again this time and ran it through just the persistent scene with the debug console prefab and it gave me the same warning once. Then never again after playing just the persistent scene. Maybe the script execution order?
     
  22. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    To verify, this issue is not present when not using this plugin, is it correct?
     
  23. mikeohc

    mikeohc

    Joined:
    Jul 1, 2020
    Posts:
    215
    Nope. No warning related to it when prefab is removed from scene.
     
  24. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @mikeohc I've spent a good chunk of time trying to pinpoint this issue and my gut feeling tells me that it is an internal Unity bug. I've created a repro for you to verify:

    In SampleScene, if you create an empty GameObject under BadCanvas and then undo&redo, the same logs will be logged. This occurs in a very specific setup: object must have a Layout Group, its child Image must have a Sprite assigned, the child Image must have an InputField child object. The super strange thing is, this can't be reproduced with GoodCanvas and I have no idea why! They're exactly the same.

    In IngameDebugConsole's case, BadCanvas=IngameDebugConsole/DebugLogWindow/Buttons, Parent=SearchbarSlotTop, InputField=Searchbar.

    I've reported this issue to Unity but I don't expect a resolution anytime soon.

    In the meantime, I've noticed that disabling Canvas Scaler component of IngameDebugConsole has a positive effect. Can you try disabling it in the Scene and inside a script's Start function, manually enable it? And can you check if it prevents the warnings in additive scene loading, as well? BTW I couldn't reproduce this issue while additive scene loading, I repeatedly hit Play button until I received these warnings at startup (it was random).
     

    Attached Files:

    mikeohc likes this.
  25. mikeohc

    mikeohc

    Joined:
    Jul 1, 2020
    Posts:
    215
    This did the trick. What's even weirder now is that
    1) Whenever I have IngameDebugConsole enabled in my persistent scene I sometimes get the same warning when:
    1a) I have this line to set the gameobject active in Awake() or OnEnable()
    _ingameDebugConsole.SetActive(false);

    1b) reload scripts with that line still in Awake() or OnEnable().

    2) When IngameDebugConsole is disabled in the scene, and enabling the GO at Start() will have no warnings.

    But I can confirm enabling the object at Start() works even for additive scene. Again, I'm not sure if it's random or what, but It's working for all the times I've tried.
     
    yasirkula likes this.
  26. WryMim

    WryMim

    Joined:
    Mar 16, 2019
    Posts:
    69
    I found a bug. With the new Input System does not work. Doesn't see the library, manually adding dependencies helped.

    upload_2023-5-24_17-6-46.png
     
    yasirkula likes this.
  27. yasirkula

    yasirkula

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

    hommfan

    Joined:
    Aug 20, 2020
    Posts:
    3
    Is there an option to scroll to bottom of window when a new log entry appears?
     
  29. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You can click the snap to bottom button at the bottom of the log window but if you'd like to do that programmatically, you can add SetSnapToBottom(true) at the end of DebugLogManager.ProcessLog function.
     
    hommfan likes this.
  30. HP_tesnn

    HP_tesnn

    Joined:
    Oct 17, 2020
    Posts:
    30
    NullReferenceException: Object reference not set to an instance of an object.
    BlockJourney.SingletonPopup`1[T].get_Instance () (at <00000000000000000000000000000000>:0)
    BlockJourney.IngamePopup+<IEShowPopup>d__18.MoveNext () (at <00000000000000000000000000000000>:0)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <00000000000000000000000000000000>:0)

    Is there any way that I can know where is the line of error instead of "<0000000000000000>"?
     
  31. xjjon

    xjjon

    Joined:
    Apr 15, 2016
    Posts:
    613
    Is your console prefab object active?
     
  32. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @HP_tesnn Apart from selecting the Development Build option, I'm unaware of a method but I hope that I'm wrong. If you do find a way that works in release builds, please let me know.
     
    HP_tesnn likes this.
  33. HP_tesnn

    HP_tesnn

    Joined:
    Oct 17, 2020
    Posts:
    30
    Of course. That's why I got the message.
     
  34. dyguests

    dyguests

    Joined:
    May 4, 2015
    Posts:
    16
    Genius tool!!!!!

    There are some suggestions:
    Its overall size is too large in portrait mode, I wish it could be reduced a bit.
     
  35. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @dyguests Thank you! If you enable the "Enable Horizontal Resizing" property from IngameDebugConsole object's Inspector, it can be resized horizontally, as well.
     
  36. kalipsa988

    kalipsa988

    Joined:
    Jul 2, 2019
    Posts:
    3
    I have random crash
    on starting game (android and ios)
    upload_2024-3-4_14-19-1.png

    usually everything is fine, but sometimes this happens, the last time I had to update the console, now I don’t know what to do
     
    Last edited: Mar 4, 2024
  37. kalipsa988

    kalipsa988

    Joined:
    Jul 2, 2019
    Posts:
    3
    there is still a feeling that awake is not working, there was often a NULL REFERENCE on canvasGroup and you need to call awake manually upload_2024-3-4_15-32-23.png
     
  38. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @kalipsa988 The exception occurs in UpdatePosition which means that canvasGroup can't be null. Could you check if DebugLogPopup's Debug Manager is assigned? If not, I'd recommend deleting the plugin and reimporting it from scratch.
     
  39. kalipsa988

    kalipsa988

    Joined:
    Jul 2, 2019
    Posts:
    3
    I was able to solve the problem by creating the console after the game is initialized, and not at the moment
    if I started the game without saving, the console generated the error graphic device is null (unity version 22.3.19f1), but if I had a save, then everything was ok
     
    yasirkula likes this.