Пример #1
0
    // Return to a previous screen if one is available
    public virtual void ReturnToPreviousScreen()
    {
        if (prevScreens.Count == 0)
        {
            return;
        }

        GameObject          oldScreen        = goCurrentPanelObj;
        UIMenuScreenManager oldScreenManager = currentScreenManager;

        string panelID       = prevScreens.Pop();
        string lastSelection = "";

        if (bStorePreviousSelections)
        {
            if (prevSelectedScreenUINames.Count > 0)
            {
                lastSelection = prevSelectedScreenUINames.Pop();
            }
        }

        sCurrentPanel        = null;
        currentScreenManager = null;
        goCurrentPanelObj    = null;

        oldScreenManager.CloseScreen(() => { OpenNewScreen(panelID, lastSelection); });
    }
Пример #2
0
    // Opens the new screen
    private void OpenNewScreen(string newPanelID, string lastSelection)
    {
        GameObject newScreen = Instantiate(dMenuScreens[newPanelID].goScreenPanel, tMenuParent);

        newScreen.SetActive(false);
        sCurrentPanel     = newPanelID;
        goCurrentPanelObj = newScreen;

        currentScreenManager = newScreen.GetComponent <UIMenuScreenManager>();

        if (currentScreenManager != null)
        {
            currentScreenManager.SetMenuManager(this);
            currentScreenManager.gameObject.SetActive(true);

            currentScreenManager.OpenScreen(lastSelection);
        }
    }
Пример #3
0
    // Initialization
    protected virtual void Awake()
    {
        playerInput = ReInput.players.GetPlayer(0);

        // If we need to clear on awake, then loop through all of the menu windows and destroy them
        if (bClearMenuParentOnAwake)
        {
            int windowCount = tMenuParent.childCount;

            if (windowCount > 0)
            {
                for (int i = 0; i < windowCount; i++)
                {
                    Destroy(tMenuParent.GetChild(i).gameObject);
                }
            }
        }

        // Set Current Panel if starting instantiated
        if (bStartInstantiated)
        {
            sCurrentPanel        = dMenuScreens.First().Key;
            goCurrentPanelObj    = Instantiate(dMenuScreens.First().Value.goScreenPanel, tMenuParent);
            currentScreenManager = goCurrentPanelObj.GetComponent <UIMenuScreenManager>();

            if (currentScreenManager != null)
            {
                currentScreenManager.SetMenuManager(this);
                currentScreenManager.gameObject.SetActive(true);

                if (!bStartNotSelected)
                {
                    currentScreenManager.OpenScreen(null);
                }
            }
        }

        prevScreens = new Stack <string>();
        prevSelectedScreenUINames = new Stack <string>();

        currentWindows = new Stack <UIMenuWindowManager>();
    }
Пример #4
0
    // Changes the Menu Screen to panel
    public virtual void GoToScreen(string panelID)
    {
        if (!dMenuScreens.ContainsKey(panelID))
        {
            return;
        }

        if (bStorePreviousSelections)
        {
            if (EventSystem.current.currentSelectedGameObject == null)
            {
                prevSelectedScreenUINames.Push("");
            }
            else
            {
                prevSelectedScreenUINames.Push(EventSystem.current.currentSelectedGameObject.name);
            }
        }

        UIMenuScreenManager oldScreenManager = null;
        GameObject          oldScreen        = goCurrentPanelObj;

        if (sCurrentPanel != null)
        {
            prevScreens.Push(sCurrentPanel);
            oldScreenManager = currentScreenManager;

            sCurrentPanel        = null;
            currentScreenManager = null;
            goCurrentPanelObj    = null;

            oldScreenManager.CloseScreen(() => { OpenNewScreen(panelID, null); });
        }
        else
        {
            OpenNewScreen(panelID, null);
        }
    }