Hello there,
I would like to destroy my menu when the player click on “Play” (or “Load Game”) but instead of that, it is launching the game but the menu stay there no matter what. I’ve tried to set un boolean to make it disappears and it actually disappears for less than a second, but after the next frame, it logically goes back to the initial value = true.
Here is the code :
using UnityEngine;
using System.Collections;
public class Menu : MonoBehaviour {
public static bool New = false;
public static bool Load = false;
bool showButton = true;
void OnGUI () {
if(showButton)
{
// Make a background box
GUI.Box(new Rect(Screen.width / 4, Screen.height/6, Screen.width /2 , Screen.height/1.5f), "Loader Menu");
// New
if(GUI.Button(new Rect(Screen.width / 2.7f, Screen.height/4, Screen.width / 4, Screen.height / 10), "New")) {
New = true;
Load = false;
Application.LoadLevel(1);
showButton = false;
}
// Load
if(GUI.Button(new Rect(Screen.width / 2.7f, Screen.height/2, Screen.width / 4, Screen.height / 10), "Load Game")) {
New = false;
Load = true;
Application.LoadLevel(1);
showButton = false;
}
// Make the second button.
if(GUI.Button(new Rect(Screen.width / 2.7f, Screen.height/1.5f, Screen.width / 4, Screen.height / 10), "Quit Game"))
{
Application.Quit();
}
}
}
}
Anyone has an idea ?
Thanks in advance!