Some code works in OnGUI(), some doesn't.

I was trying to make a dev console for my game using simple GUI system.

void OnGUI()
	{
		if (devConsoleToggle)
		{
			devInput = GUI.TextField(new Rect(0, 0, 150, 30), devInput);  //this part works...

			pauseMenu.SeemsPausedOn();

			if (Input.GetKeyDown(KeyCode.Return))
			{
				if (devInput.Split(' ')[0] == "info")
				{
					string commDescToGet = devInput.Split(' ')[1];
					Command commDescToShow = Array.Find(commands, command => command.name == commDescToGet);
					GUI.Label(new Rect(100f, 100f, 20f, 400f), commDescToShow.description);  //...but this doesn't
					devConsoleToggle = false;
				}
			}
		}
		else pauseMenu.SeemsPausedOff();
	}

GUI.TextField works perfectly fine, but GUI.Label doesn’t. I was forced to do it by Unity 4.6’s new UI. Can someone tell me why this isn’t working?

1 Answer

1

It’s 2017, OnGUI has been dropped years ago.

Why are you still using it?