I have a boolean called canLoad in my script. I set it to true in the code and in the inspector it’s unchecked. I use it in the Menu_SP() method and when I start the game, it behaves how it should if it were false but it’s set to true. Why is this?
public class menuManager : MonoBehaviour {
public string currentMenu;
public bool canLoad = true;
public GUIStyle menuBG;
public GUIStyle Labels;
public GUIStyle Buttons;
public GUIStyle smallButtons;
public GUIStyle notYetBttn;
public GUIStyle Text;
public GUIStyle smallText;
void Start () {
currentMenu = "Main";
}
void Update () {
}
void OnGUI() {
if(currentMenu == "Main")
Menu_Main();
if(currentMenu == "SP")
Menu_SP();
if(currentMenu == "Opt")
Menu_Opt();
}
public void NavigateTo(string nextmenu) {
currentMenu = nextmenu;
}
public void Menu_Main() {
GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "", menuBG);
GUI.Label(new Rect(400, 50, 300, 50), "IDGAF", Labels);
if(GUI.Button(new Rect(400, 150, 300, 50), "Singleplayer", Buttons)) {
NavigateTo("SP");
}
if(GUI.Button(new Rect(400, 210, 300, 50), "Multiplayer", notYetBttn)) {
}
if(GUI.Button(new Rect(400, 270, 300, 50), "Options", notYetBttn)) {
}
if(GUI.Button(new Rect(400, 330, 300, 50), "Exit", Buttons)) {
Application.Quit();
}
}
public void Menu_SP() {
GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "", menuBG);
GUI.Label(new Rect(400, 50, 300, 50), "Singleplayer", Labels);
if(GUI.Button(new Rect(400, 150, 300, 50), "New Game", Buttons)) {
}
if(canLoad == true){
if(GUI.Button(new Rect(400, 210, 300, 50), "Load Game", Buttons)) {
}
}
else if(canLoad == false) {
if(GUI.Button(new Rect(400, 210, 300, 50), "Load Game", notYetBttn)) {
}
}
if(GUI.Button(new Rect(400, 270, 300, 50), "Back", Buttons)) {
NavigateTo("Main");
}
}
public void Menu_Opt() {
}
}