help a newbie with the buttons in the menu

I want to make the menu.

function OnGUI() {
if(GUI.Button(new Rect(0, 0, 100, 50),“MENU”))
{
if(GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 102, 100, 50),“START”))
{}
if(GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 50, 100, 50),“HELP”))
{}
if(GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 +2, 100, 50),“NETWORK”))
{}
if(GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 + 54, 100, 50),“EXIT”))
{}

}

}

When I click on the menu does not displayed other buttons

Just a fast answer, so you could go on:

You can’t do it this way, because a button click is a single action. That means clicking the MENU button only give a single call to show the other buttons. Example in real life: You want to switch on the light, but the button turn off right after you pressed it. It will be dark always. :wink:

Your button click on MENU must call something like this:

using UnityEngine;
using System.Collections;

public class guitests : MonoBehaviour {
	
	public static bool DisplayButtons = false;
			
	void OnGUI () {
		
	
		if(GUI.Button(new Rect(0, 0, 100, 50),"MENU")) {
		
		DisplayButtons = true;
		
		}

			if(DisplayButtons == true) {
				
			if(GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 102, 100, 50),"START"))
			{}
			if(GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 50, 100, 50),"HELP"))
			{}
			if(GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 +2, 100, 50),"NETWORK"))
			{}
			if(GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 + 54, 100, 50),"EXIT"))
			{}		
						
			}	
		
	}	
	

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		
	}
}

You see, when you click now MENU the variable DisplayButtons is set to true. As long as DisplayButtons is set to true, the other buttons will be shown.

Of course you want to be able to disable the buttons again clicking one MENU. If you need, tell me. If you have questions, tell me.

Please: When posting code, click on “Go Advanced” and click # after you marked your code. That way code is more readable.

thank you very much!

Welcome!