Search Unity

Question Can I force Debug.Log() to print my message in one bubble in the console?

Discussion in 'Scripting' started by babaliaris, Jan 18, 2021.

  1. babaliaris

    babaliaris

    Joined:
    Apr 21, 2013
    Posts:
    40
    I have the following Debug code:

    Code (CSharp):
    1. //Debug Stuff.
    2.             if (Debug.isDebugBuild)
    3.             {
    4.                 //Time remaining.
    5.                 Debug.Log($"Shortcut {gameObject.name} cooldown remaining: {CoolDownTime - m_CoolDownTimer}s");
    6.             }
    Because the CoolDownTime - m_CoolDownTimer is different in each frame, unity will print that message in a different "bubble".

    I'm wondering if there is a way to force the Debug.Log() to print that message in the same "bubble" like when it does with messages that are printed multiple times and increase a counting number in the right side of the "bubble".

     
    SparrowGS likes this.
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    Probably not. I don't think the basic Debug.Log is that complex. It would have to know how to split off the part that is different from the rest, which I think would also slow it down. Debug.Log just creates a string which it does some basic comparison on to determine if it needs to stack it or not. It would have no way of knowing what part needs to be tracked "on it's own" from the string. This is just my guess on how it works, but I think if you wanted something different, you'll need to look for a custom solution.
     
    babaliaris likes this.