public override void SceneAwake(Singleton instance) { // Clear out all the menus managedMenusStack.Clear(); // Populate typeToMenuMap dictionary SceneTransitionMenu transitionMenu = null; PopulateTypeToMenuDictionary(typeToMenuMap, out transitionMenu); // Attempt to find a pop-up manager popUpManager = FindObjectOfType <PopUpManager>(); // Check to see if there was a transition menu if (transitionMenu == null) { // If not, run the scene manager's transition-in events immediately TransitionManager.TransitionIn(null); } else { // If so, run the transition menu's transition-in animation transitionMenu.Hide(TransitionManager.TransitionIn); } }
internal void TransitionIn(IMenu menu) { // Check to see if the argument for the next menu is provided SceneTransitionMenu transitionMenu = menu as SceneTransitionMenu; if (transitionMenu == null) { // If not, we're not transitioning, so run both transition-out events at the same time if (OnSceneTransitionInStart != null) { OnSceneTransitionInStart(menu); } if (OnSceneTransitionInEnd != null) { OnSceneTransitionInEnd(menu); } } else { // If so, check to see the current menu state if ((transitionMenu.CurrentTransition == SceneTransitionMenu.Transition.SceneTransitionInStart) && (OnSceneTransitionInStart != null)) { // If just transitioning in, run the transition-out start event OnSceneTransitionInStart(menu); } else if ((transitionMenu.CurrentTransition == SceneTransitionMenu.Transition.SceneTransitionInEnd) && (OnSceneTransitionInEnd != null)) { // If transitioning ended, run the transition-out end event OnSceneTransitionInEnd(menu); } } }
public void LoadScene(SceneInfo scene) { // Make sure the parameter is correct if (scene == null) { throw new ArgumentNullException("scene"); } else if (string.IsNullOrEmpty(scene.ScenePath) == true) { throw new ArgumentException("No scene name is set", "scene"); } // Check if we need to update the last scene if (CurrentScene != scene) { lastScene = CurrentScene; } // Update which scene to load sceneToLoad = scene; // Make sure we have a level to load if (sceneToLoad != null) { // Show the level transition menu SceneTransitionMenu transitionMenu = Singleton.Get <MenuManager>().Show <SceneTransitionMenu>(TransitionOut); // Check if there's a transition menu if (transitionMenu == null) { // Just load the scene without the menu TransitionOut(null); } } }
void TransitionOut(IMenu menu) { // Check to see if the next scene name is provided if (sceneToLoad != null) { // Check to see if the argument for the next menu is provided SceneTransitionMenu transitionMenu = menu as SceneTransitionMenu; if (transitionMenu == null) { // If not, we're not transitioning, so run both transition-out events at the same time if (OnSceneTransitionOutStart != null) { OnSceneTransitionOutStart(menu); } if (OnSceneTransitionOutEnd != null) { OnSceneTransitionOutEnd(menu); } // Transition to the next scene TransitionToScene(loadLevelAsynchronously, sceneToLoad); } else { // If so, check to see the current menu state if (transitionMenu.CurrentTransition == SceneTransitionMenu.Transition.SceneTransitionOutStart) { // If just transitioning in, run the transition-out start event if (OnSceneTransitionOutStart != null) { OnSceneTransitionOutStart(menu); } // Play the sound effect if (soundEffect != null) { soundEffect.Play(); } } else if (transitionMenu.CurrentTransition == SceneTransitionMenu.Transition.SceneTransitionOutEnd) { // If transitioning ended, run the transition-out end event if (OnSceneTransitionOutEnd != null) { OnSceneTransitionOutEnd(menu); } // Transition to the next scene TransitionToScene(loadLevelAsynchronously, sceneToLoad); } } } }
void PopulateTypeToMenuDictionary(Dictionary <Type, IMenu> typeToMenuDictionary, out SceneTransitionMenu transitionMenu) { // Setup variables int index = 0; transitionMenu = null; typeToMenuDictionary.Clear(); // Populate items to ignore into the type map for (; index < IgnoreTypes.Length; ++index) { typeToMenuDictionary.Add(IgnoreTypes[index], null); } // Search for all menus in the scene IMenu[] menus = UnityEngine.Object.FindObjectsOfType <IMenu>(); if (menus != null) { // Add them into the dictionary Type menuType; IMenu displayedManagedMenu = null; for (index = 0; index < menus.Length; ++index) { if (menus[index] != null) { // Add the menu to the dictionary menuType = menus[index].GetType(); if (typeToMenuDictionary.ContainsKey(menuType) == false) { // Add the menu typeToMenuDictionary.Add(menuType, menus[index]); // Check if this menu is a SceneTransitionMenu if (menuType == typeof(SceneTransitionMenu)) { transitionMenu = (SceneTransitionMenu)menus[index]; } } // Check if this is the first displayed, managed menu if ((menus[index].MenuType == IMenu.Type.DefaultManagedMenu) && (displayedManagedMenu == null)) { // Grab this menu displayedManagedMenu = menus[index]; // Indicate it should be visible displayedManagedMenu.Show(); } } } } }