Debug.Log doesn't get called when Unity freezes?

In my scene I have 2 Charas (Wasch and Lucat) walking next to each other.

By hitting space, the player can switch between the two, which ever he wants to “posses”.

One script controlls the switching.

Another script takes care of the camera-movement (handled with waypoints)

The Controller-Script:

private var waschActive : boolean = false;

private var camCall = GameObject.Find("Main Camera").GetComponent("CamMove");

function Update () 
	if (Input.GetButtonDown("Jump")) // on Spacebar down, do:
		// switch between Charas
		waschActive = !waschActive;

		// tell the MainCam, which PC to possess
		if ( waschActive )

Here's the function that gets activated by the camCall.

function LucatToWasch ()
 Debug.Log("LucatToWasch started");
 while ( !lastPointReached )
	//as long as first waypoint hasn't been reached yet, 
	//lerp Camera towards it and make it face in the same direction		
	while ( !firstPointReached)
		Debug.Log("First Point not reached yet");
		transform.position = Vector3.Lerp 
			(camPositionLucat.position, camPathPointLucat.position, 5);

		if (cameraTrans.position == camPathPointLucat.position)
			Debug.Log("first Waypoint reached");
			firstPointReached = true;

Currently the camCall is commented out and if I hit space I get the "WaschActive"-Message.

(Other functionalities I implemented and left out for clarity work perfect as well)

Now the strange thing is: if I un-comment it, Unity freezes before it even prints the "WaschActive"-Message! O.o No Debug.Log-calls at all (non of the camMove-script either). No errors. The statistics-window freezes as well...

So what's happening?

Does Unity freez before it even reaches the problematic code??

Will Debug.Log not get called if it freezes.

Thanks a lot in advance!

Greetz, Ky.



As burnumd said and GargerathSunman on the Forums confirmed, Unity will always hang before drawing Debug.Log!! So for infinite Loops, Debug.Log won’t do…

I put in some yield; and now it doesn't crash anylonger! =D It's still weird, but sort of works... =)

Your camera code is a real problem.

You use while loops in there, that never use yield. That means they run at full power and prevent any other code in your project and in case of editor running the editor, from doing anything at all.
Thats an infinite loop and within the editor, the editor will just forcefully kill it if it detects that

What's likely happening is that those while loops are just spinning away causing Unity to freeze before it gets a chance to redraw the console. If you check the actual logs (press "Open Editor Log" in the control bar of the console before you hit play), you should see your log messages at the very end.