🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

show/hide window in Unity3d

Started by
1 comment, last by rogerdv 9 years, 1 month ago

Im working to implement my RPG conversation system, which in previous projects (other engines) I managed with a whole game state. In Unity3d Im still trying to figure how how to handle it, but I decided to start witha simple box to display questions and choices. The problem is that GUI.Box is not displaying anything, using this code:


public class Dialog : MonoBehaviour {

	private static bool render = false;

	public static void ShowDialog(bool toggle){
		render = toggle;
	}

	void OnGui() {
		if (render) {
			GUI.Box(new Rect(2, Screen.height-300, Screen.width-2, Screen.height-2), "Dialog");
			
		}
	}
}

The code that must show the box is this:


if (Input.GetKey (KeyCode.I))
	Dialog.ShowDialog (true);

Can somebody see whats wrong here?

Advertisement

You have to use OnGUI, not OnGui !!!

http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnGUI.html

My eyes are playing tricks with me. I have just compared it witha code with acorrect OnGUI, and I swear I saw OnGui.

This topic is closed to new replies.

Advertisement