Making GUI Components in/visible ?

I am trying to make it so when the user clicks a button, a box appears with a text field and a password field. I have the following script:

function OnGUI ()
{
	// Define variables needed:
	var newGameClicked : boolean;
	var loadGameClicked : boolean;
	
	GUI.Box(Rect(Screen.width/2-100,10,200,100), "Main Menu:");
	
	if(GUI.Button(Rect(Screen.width/2-90, 40, 180, 30), "New Character"))
	{
		newGameClicked = true;
	}
	if(GUI.Button(Rect(Screen.width/2-90, 70, 180, 30), "Load Character"))
	{
		loadGameClicked = true;
	}
	
	if(newGameClicked)
	{
		GUI.Label(Rect(Screen.width/2, 200, 100,20), "Test (This would be the TextField)");
		GUI.Label(Rect(Screen.width/2, 250, 100,20), "Test (This would be the PasswordField)");
	}
}

Thanks for any help you provide!
~Nick

add a state that tells if you if them shall be shown

if that state (boolean variable) is true, then call the gui.xxxx functions, otherwise just don’t call them

I think that’s what I did in my script…right? If it is what you said, it’s not working…

It looks like you’ve got the right idea, but I think your logic is a bit out.

a) the booleans should be declared outside the OnGUI(). (so its not reset every update)
b) the booleans need a state initalised to start with.
c) there is no code to undisplay them. (like after validating name/password)

Thank you! My problem was the variables being reset. I thought variables started out as “false” if they were booleans …? They did for me anyways. Thanks again!