Hello guys/girls,
Finally found out how to write a start menu script with the build in gui system.
However I’m running into a problem.
When I click the options button my options menu appears.
But when I then click on credits the options menu is still there with the overlaying credits menu.
How can I fix this?
using UnityEngine;
using System.Collections;
public class Layouttest : MonoBehaviour
{
public bool showOptions = false;
public bool showCredits = false;
private int guiButtonWidth = 100;
void OnGUI ()
{
GUILayout.BeginArea (new Rect (0, 0, 200, 300));
GUILayout.BeginVertical ();
if (GUILayout.Button ("Start Game")) {
Application.LoadLevel (4);
}
if (GUILayout.Button ("Options")) {
showOptions = true;
}
if (GUILayout.Button ("Credits")) {
showCredits = true;
}
if (GUILayout.Button ("Quit Game")) {
Application.Quit ();
}
GUILayout.EndVertical ();
GUILayout.EndArea ();
if (showOptions) {
showOptions = true;
GUILayout.BeginArea (new Rect (210, 0, 200, 300));
GUILayout.BeginHorizontal ();
//text column
GUILayout.Label ("Quality settings", GUILayout.Width (100));
GUILayout.EndHorizontal ();
//settings column
GUILayout.BeginHorizontal ();
GUILayout.Button ("Fastest");
GUILayout.Button ("Fast");
GUILayout.Button ("Simple");
GUILayout.Button ("Good");
GUILayout.Button ("Beautiful");
GUILayout.Button ("Fantastic");
GUILayout.EndHorizontal ();
GUILayout.EndArea ();
} else {
showOptions = false;
}
if (showCredits) {
showCredits = true;
GUILayout.BeginArea (new Rect (210, 0, 200, 300));
GUILayout.BeginHorizontal ();
GUILayout.Button ("You did it");
GUILayout.EndHorizontal ();
GUILayout.EndArea ();
} else {
showCredits = false;
}
}
}