My unity has gone INSANE!

I’ve just wasted the last 5 hours painstakingly trying to debug this function to no avail. I have broken it down to the most simplest of code blocks and it would seem it has now moved from obvious bug to the twilight zone and as a last resort I am coming on here for any clues as to what it might be.

Long story short, weird things were happening, I started to debug the code and I was finding certain Debug.Log statements were not being called. I racked my brain to think what could be causing a Debug.Log in the middle of a function to be called over and over but the Log message that was the first line of that function was never output. I removed all code so that function was completely empty apart from a Debug.Log, then nothing was output at all. Well obviously as anyone would think, the function is not being called! Thats what I thought, then I put a Debug.Log the line before the call to that function and that message worked. I put a Debug.Log after the line calling that function and that also was output but the Debug.Log INSIDE that function being called was not being output.

Starting to get rather nervous and concerned at my own sanity I started to fool around more and the more I played with the messages, the more things were not being output. The message that was working before the function was called I added some text to, and this was reflected in the output. I then appended a test function call to the Debug.Log, something like

Debug.Log(“START HERE 1” + simpleFunction());

Now that entire Log entry has vanished. I put it back to the way it was before I tried appending the function, and its completely gone still. However a Debug.Log immediately following still works.

It’s almost as if everything I touch will now get erased from exhistance if it calls another function and that line of code is poisoned forever.

Could this be the end of my sanity or is unity having a nervous breakdown?

The only thing I noticed which i thought was interesting was that the Script file is showing as 8999 lines long in Unitron. Have I crossed the LOC count between the sane world and the world of chaos perhaps!

HELP!

Ok… have really simplified it now so I can post some sample code.

Here is a function that is being called every frame:

void UpdateNEWGhostStuff()
{
Debug.Log("DEBUG LINE 1 - " + Time.time);
Debug.Log(“DEBUG LINE 2”);
Debug.Log(“DEBUG LINE 3 --------------------”);
}

The debug output is only printing the first line "DEBUG LINE 1 - " + the time over and over… The following 2 debug lines are being ignored.

See image below:

I think I have found the problem… It seems that the little ‘COLLAPSE’ tab at the top of the debug window is hiding the other two messages from view. It’s always the little things.

Seems strange that collapse would hide some debug messages but not others. Before it was printing two in the same function scope and now its ignoring 2 out of 3 in the same function scope. Either way, back to debugging for me, if that is all it is then I feel a bit silly for burning 5 hours trying to find the bug.

I must have hit ‘collapse’ by accident when hitting the clear button. :frowning:

Collapse hides messages that have already been printed. The purpose being that you don’t have to sift through thousands of duplicate “Debug line 2” printouts just to find the one that’s actually changing. That said, I pretty much never use it and I think it should be off by default, because I’ve lost track of the number of times I’ve written “turn collapse off in the console” in response to variations of “why doesn’t debug log print anything?”

–Eric