public void actavateMenuOverlay( GUIGlobals.menuTypeDefs overlay ) { if( _menuRefList[ (int)overlay ].activeSelf == false ) { _currentOverlay = overlay; _menuRefList[ (int)_currentOverlay ].SetActive( true ); _menuRefList[ (int)_currentMenu ].GetComponent<MenuBase>()._overlay = true; } }
// Use this for initialization public void Initialize() { // Start Initialize. menuList = new GameObject(); menuList.name = GUIGlobals.MENU_LIST_OBJECT_NAME; menuList.tag = GUIGlobals.MENU_LIST_OBJECT_TAG; _menuRefList = new List<GameObject>(); listCount = GUIGlobals.numberOfMenus; for( i = 0; i < listCount; i++ ) { // Start menu for loop. // Grabing the the button texture list: listCount2 = GUIGlobals.menuButtonTexurePathList.GetLength(1); tempPathList = new string[ listCount2 ]; for( j = 0; j < listCount2; j++ ) { if( GUIGlobals.menuButtonTexurePathList[i,j] != "" ) tempPathList[j] = GUIGlobals.menuButtonTexurePathList[i,j]; } // Grabing the the button rect list: listCount2 = GUIGlobals.menuButtonToolTips.GetLength(1); tempTipList = new string[ listCount2 ]; for( j = 0; j < listCount2; j++ ) { if( GUIGlobals.menuButtonToolTips[i,j] != "" ) tempTipList[j] = GUIGlobals.menuButtonToolTips[i,j]; } // Grabing the the button rect list: listCount2 = GUIGlobals.menuButtonRectList.GetLength(1); tempRectList = new Rect[ listCount2 ]; for( j = 0; j < listCount2; j++ ) { if( GUIGlobals.menuButtonRectList[i,j] != null ) tempRectList[j] = GUIGlobals.menuButtonRectList[i,j]; } if( GUIGlobals.menuNameList[i] == "Options" ) _tempMenu = Instantiate( Resources.Load( "Menus/OptionsMenu", typeof(GameObject)) ) as GameObject; else if( GUIGlobals.menuNameList[i] == "Extras" ) _tempMenu = Instantiate( Resources.Load( "Menus/ExtrasMenu", typeof(GameObject)) ) as GameObject; else _tempMenu = Instantiate( Resources.Load( "Menus/Menu", typeof(GameObject)) ) as GameObject; _menuRefList.Add( _tempMenu ); _tempMenu.name = GUIGlobals.menuNameList[i]; _tempMenu.tag = "Menu"; _tempMenu.GetComponent<MenuBase>().initialize( GUIGlobals.menuTypeList[i], GUIGlobals.menuBackgroundTexturePathList[i], tempPathList, tempTipList, tempRectList ); _tempMenu.SetActive(false); _tempMenu.transform.parent = menuList.transform; } // End menu for loop. setCurrentMenu( GUIGlobals.menuTypeDefs.MAIN ); _previousMenu = GUIGlobals.menuTypeDefs.MAIN; SettingsData.getInstance().SoundVolume = 0.2f; }
public void setCurrentMenu( GUIGlobals.menuTypeDefs menuType ) { // Start setCurrentMenu. if( !_menuRefList[ (int)menuType ].activeSelf && menuType != GUIGlobals.menuTypeDefs.NONE ) { _menuRefList[(int)_currentMenu ].SetActive(false); _previousMenu = _currentMenu; _currentMenu = menuType; _menuRefList[(int)_currentMenu ].SetActive(true); } else _menuRefList[(int)_currentMenu ].SetActive(false); }
// Use this for initialization public void initialize( GUIGlobals.menuTypeDefs menuType, string backgroundPath, string[] buttonPathList, string[] toolTipList, Rect[] buttonPositionList ) { // Start Constructor. // Misc: _nothingActive = GUIGlobals.NOTHING; // Setting the menuType and name: _menuType = menuType; _menuName = GUIGlobals.menuNameList[ (int)menuType ]; // Tool Tip Settings: _toolTipList = toolTipList; _toolTipTimmer = 0.0f; ToolTipDelay = GUIGlobals.toolTipDelay; // Setting the active button to null just in case: _currentActiveButtonTexture = null; _currentActiveButtonIndex = _nothingActive; // Axis input related variables: if( axesInputDelayControl == null ) axesInputDelayControl = AxesInputDelayControl.getInstance(); _mouseInputSecondary = false; // Keyboard Input Variables: menuHardCodedOkButton = KeyCode.Return; // Loading the background: _backgroundTexture = (Texture2D)Resources.Load( backgroundPath, typeof(Texture2D)); // Loading the button Graphics and calculating the number of buttons seprate of states: listCount = buttonPathList.Length; _buttonTextureList = new List<Texture2D>(); for( i = 0; i < listCount; i++ ) { if( buttonPathList[i] != null ) _buttonTextureList.Add( (Texture2D)Resources.Load( buttonPathList[i], typeof(Texture2D)) ); } _numberOfButtons = ( _buttonTextureList.Count / GUIGlobals.numberOfButtonStates ); // Setting the button positions: listCount = _numberOfButtons; _buttonRectList = new List<Rect>(); for( i = 0; i < listCount; i++ ) { // No need for null checking since we alerady know how many buttons there are. _buttonRectList.Add( buttonPositionList[i] ); } // Grabing Game Object Refernces: //if( gameData == null ) //gameData = GameObject.FindGameObjectWithTag("GameData").GetComponent<GameData>(); if( menuGenerator == null && menuType != GUIGlobals.menuTypeDefs.PAUSE ) menuGenerator = MenuGenerator.getInstance(); // Setting Menu draw size and order: if( menuType == GUIGlobals.menuTypeDefs.PAUSE || menuType == GUIGlobals.menuTypeDefs.TROPHIES_WARNING || menuType == GUIGlobals.menuTypeDefs.SCORE_WARNING ) { MenuRectangle = new Rect( ( 1280 - _backgroundTexture.width ) / 2, ( 720 - _backgroundTexture.height ) / 2, _backgroundTexture.width, _backgroundTexture.height ); guiDepth = 0; } else { MenuRectangle = new Rect( 0, 0, 1280, 720 ); guiDepth = 1; } // Misc variables: bool overlay; // Calling the Initalize on the inheriting class: OnInitialize(); }