I am trying to make a menu and when you click on a menu,it needs to disapear and another one needs to get active.
I followed a youtube tutorial and i did exactly like there but it does not work.
I attached the MainMenu panel and OptionsPanel to currentstates.
And when i press any button i can see in the console the debug text.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MenuScript : MonoBehaviour {
// enum states
public enum MenuStates { Main, Options};
public MenuStates currentstate;
//panel objects
public GameObject mainMenu;
public GameObject optionsMenu;
//when script starts
void Awake()
{
//allways set first menu
currentstate = MenuStates.Main;
}
void update()
{
//check current state
switch (currentstate)
{
case MenuStates.Main:
//set active gameobject for main menu
mainMenu.SetActive(true);
optionsMenu.SetActive(false);
break;
case MenuStates.Options:
optionsMenu.SetActive(true);
mainMenu.SetActive(false);
break;
}
}
public void OnStartGame()
{
Debug.Log("Start Button");
}
public void OnOptions()
{
Debug.Log("Options pressed");
currentstate = MenuStates.Options;
}
public void OnWIndowedMode()
{
Debug.Log("On windowed pressed");
}
public void OnMainMenu()
{
Debug.Log("Back button pressed");
currentstate = MenuStates.Main;
}
}