/// <summary> /// Request/Announce scene loading /// </summary> private void OnLoadSceneCommand(LoadSceneCommandEvent e) { if (!e.Handled) { Log.Debug(string.Format("MenuManager.OnLoadSceneCommand({0})", e)); // turn off menus State = MenuState.Closed; if (CurrentScene == e.SceneName) { // TODO: Add e.Force to reload if needed Log.Debug(string.Format("MenuManager.OnLoadSceneCommand({0}) skipping, already loaded", e)); return; } switch (e.Mode) { case LoadSceneMode.Additive: UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName: e.SceneName, mode: UnityEngine.SceneManagement.LoadSceneMode.Additive); break; default: UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName: e.SceneName, mode: UnityEngine.SceneManagement.LoadSceneMode.Single); break; } CurrentScene = e.SceneName; } else { Log.Verbose(string.Format("MenuManager.OnLoadSceneCommand({0}) scene loaded", e)); // do nothing } }
/// <summary> /// Request/Announce scene loading /// </summary> void OnLoadSceneCommand(LoadSceneCommandEvent e) { if (e.Handled) { Log.Debug(string.Format("GameManager.OnLoadSceneCommand({0})", e)); if (e.SceneName == ApplicationConstants.MainScene) { State = GameState.Ready; } } }
/// <summary> /// Request to load a scene /// </summary> void OnLoadSceneCommand(LoadSceneCommandEvent e) { if (!e.Handled) { Log.Debug(string.Format("MenuManager.OnLoadSceneCommand({0})", e)); // turn off menus State = MenuState.Closed; if (CurrentScene == e.SceneName) { // TODO: Add e.Force to reload if needed Log.Debug(string.Format("MenuManager.OnLoadSceneCommand({0}) skipping, already loaded", e)); return; } switch (e.Mode) { case LoadSceneMode.Additive: UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName: e.SceneName, mode: UnityEngine.SceneManagement.LoadSceneMode.Additive); break; default: UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName: e.SceneName, mode: UnityEngine.SceneManagement.LoadSceneMode.Single); break; } CurrentScene = e.SceneName; // notify event Events.Raise(new LoadSceneCommandEvent() { Handled = true, SceneName = CurrentScene, Mode = e.Mode }); } }