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); } }
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(); } } } } }