/// <summary> /// Switch to another UI_Screen. Won't switch if the current scene is the same as the one to switch to. /// </summary> /// <param name="screen"></param> public void SwitchScreen(UI_Screen screen) { if (screen == _currScreen) { return; } switchScreen(screen); }
private void switchScreen(UI_Screen screen) { if (screen) { if (_currScreen) { _currScreen.CloseScreen(); _prevScreen = _currScreen; } _currScreen = screen; _currScreen.gameObject.SetActive(true); _currScreen.StartScreen(); if (OnSwitchedScreen != null) { OnSwitchedScreen.Invoke(); } } }
/// <summary> /// Switch to UI_Screen regardless of if this is the current scene /// </summary> /// <param name="screen"></param> public void ForceSwitchScreen(UI_Screen screen) { switchScreen(screen); }