コード例 #1
0
    private void Update()
    {
        //If the title screen is active, move using the up/down and WS keys.
        if (titleScreen.activeInHierarchy)
        {
            //Activate the title screen cursor and deactivate the level select cursor -- ran when the title screen loads.
            if (!titleScreenCursor.IsActive())
            {
                titleScreenCursor.SetActive();
            }
            if (levelSelectionCursor.IsActive())
            {
                levelSelectionCursor.Deactivate();
            }

            //Move to the next or previous cursor.
            if (Input.GetKeyDown("down") || Input.GetKeyDown("s"))
            {
                titleScreenCursor = titleScreenCursor.ActivateNext();
                titleScreenIndex  = titleScreenCursor.GetIndex();
            }
            else if (Input.GetKeyDown("up") || Input.GetKeyDown("w"))
            {
                titleScreenCursor = titleScreenCursor.ActivatePrevious();
                titleScreenIndex  = titleScreenCursor.GetIndex();
            }


            //Activating menus
        }
        else if (levelSelectionScreen.activeInHierarchy)
        {
            //Activate the level selection screen cursor and deactivate the level select cursor -- ran when the level selection screen loads.
            if (!levelSelectionCursor.IsActive())
            {
                levelSelectionCursor.SetActive();
            }
            if (titleScreenCursor.IsActive())
            {
                titleScreenCursor.Deactivate();
            }

            //Move to the next or previous cursor.
            if (Input.GetKeyDown("right") || Input.GetKeyDown("d"))
            {
                levelSelectionCursor = levelSelectionCursor.ActivateNext();
                levelSelectionIndex  = levelSelectionCursor.GetIndex();
            }
            else if (Input.GetKeyDown("left") || Input.GetKeyDown("a"))
            {
                levelSelectionCursor = levelSelectionCursor.ActivatePrevious();
                levelSelectionIndex  = levelSelectionCursor.GetIndex();
            }
        }

        HandleSelection();
    }