void Update() { if (currentState != targetState) { StopCoroutine(currentState.ToString()); previousState = currentState; currentState = targetState; StartCoroutine(currentState.ToString()); } }
public void SwitchMenu(MenuStates toState) { //will always switch to loading menu if the Gamemanager is still loading //and then que the next menu transition while loading isn't complete if (GameManager.instance.isLoading && toState != MenuStates.Loading && !isMenuQued) { //if (GameManager.instance.debugMode) // Debug.Log("Queing Menu of type: " + toState.ToString()); isMenuQued = true; //override set the loading screen while other qued StartCoroutine(MenuQued(toState)); toState = MenuStates.Loading; } //disables all the menus first, before turning on the specific one for (int i = 0; i < menus.Count; i++) { menus[i].enabled = false; } menus.Single(x => x.name == string.Format("Menu_{0}", toState.ToString())).enabled = true; }
private void SwitchTo(MenuStates states) { //Debug.Log("Menu/" + states.ToString()); transform.Find("Menu/" + states.ToString()).gameObject.SetActive(true); }