OnGui() Causing lag, am I doing it wrong?

Hey guys,

When I added this line of code, my game gets super laggy.

		void OnGUI() 
	{
			
		if (nanoStage1States == NanoStage1States.Level1)
		{	

			pressed = GUILayout.Toggle(pressed, "Toggle me !", "Button");
			Debug.Log(pressed);
		}
		Debug.Log(nanoStage1States);
	}

When level1 becomes true, the fps drops from 70-80 to like 20-30. The profiler also pointed to it. I commented it out and there lag went away.

Is there a better way to do this?

Thanks a lot :slight_smile:

OnGui is notoriously slow!! I would just avoid using it.