for loop in OnGUI function

hey guys i have a big frame problem:

i call a window function from ongui.
in this window is a for loop…

for(var pos = 0; pos <= 9; pos++){

    Debug.Log(pos + "is written");

}

when i open thewindow via GetKeyDown the FPS drops from 400 down to 1.4…

why is this happening?
how to fix?

thanks for ur help :wink:

Robert

Try disabling the Debug.Log(), that always takes a hit on the performance in loops. Also make sure if this is what you really want. The loop will be executed every frame again.

the debug log should lower the framerate so hard?

Ok ill try but i dont think it is…

And yeah its what i need:
It draws textures an labels in a scrollview.all out of arrays

Have you tried this?

private var show = false;

function Update () {
	if (Input.GetKeyDown("0"))
		show = !show;
	if (show)
	{
		if (Time.timeScale != 0.0)
		{
			var fps : int = 1.0 / Time.deltaTime;
			guiText.text = fps.ToString();
		}
		else
		{
			guiText.text = "0";
		}
	}
	else
	{
		guiText.text = "";	
	}
}

@script RequireComponent(GUIText)

buuhh ya XD

the debug.log was the problem !?

didnt think that this small thing can cause something big:smile:

BUT: if u think ur to small, uve never been in bed with a mosquito xD

thanks