GUI script issue

I can see the button in the game view but when I press it theres no GUI boxes or labels that pop up.

function OnGUI () {
if (GUI.Button (Rect (20,70,80,30), "A")) {
		GUI.Box (Rect (10,10,100,90), "B");
		GUI.Box (Rect (130,80,250,300), "C");
		GUI.Label(Rect(140,100,80,20), "D ");
		GUI.Label(Rect(140,120,80,20), " E ");
		GUI.Label(Rect(140,140,80,20), "F");
		GUI.Label(Rect(140,160,120,20), " G ");
		GUI.Label(Rect(140,180,120,20), "H ");
		GUI.Label(Rect(140,200,120,20), " I ");
		GUI.Label(Rect(140,240,200,60), "J");
		GUI.Label(Rect(140,280,200,100), " K");
	}
}

It would seem to me , that based on that code, the other Controls would only pop up … if the other button remained pressed the whole time , which it doesnt.

function OnGUI () {
if (GUI.Button (Rect (20,70,80,30), "A")) {
        buttonPressed = true;
}

if(buttonPressed == true){
       GUI.Box (Rect (10,10,100,90), "B");
        GUI.Box (Rect (130,80,250,300), "C");
        GUI.Label(Rect(140,100,80,20), "D ");
        GUI.Label(Rect(140,120,80,20), " E ");
        GUI.Label(Rect(140,140,80,20), "F");
      GUI.Label(Rect(140,160,120,20), " G ");
        GUI.Label(Rect(140,180,120,20), "H ");
        GUI.Label(Rect(140,200,120,20), " I ");
        GUI.Label(Rect(140,240,200,60), "J");
        GUI.Label(Rect(140,280,200,100), " K");
}

}

ah ok thanks. just needed to add a variable to your version declaring what buttonPressed is and it works.

Is there anyway to make it so if you press the button again or pressed another button that text would go away? Or can you point me in the right direction to figure it out.

You could do something like this (for one button):

function OnGUI () {

if (GUI.Button (Rect (20,70,80,30), "A")) {

        buttonPressed = !buttonPressed;

}

 

if(buttonPressed){

       GUI.Box (Rect (10,10,100,90), "B");

        GUI.Box (Rect (130,80,250,300), "C");

        GUI.Label(Rect(140,100,80,20), "D ");

        GUI.Label(Rect(140,120,80,20), " E ");

        GUI.Label(Rect(140,140,80,20), "F");

      GUI.Label(Rect(140,160,120,20), " G ");

        GUI.Label(Rect(140,180,120,20), "H ");

        GUI.Label(Rect(140,200,120,20), " I ");

        GUI.Label(Rect(140,240,200,60), "J");

        GUI.Label(Rect(140,280,200,100), " K");

}

 

}