Exemple #1
0
    public void PopPanel()
    {
        if (!ready)
        {
            return;
        }
        if (!currentPanel.CanPopPanel())
        {
            return;
        }

        if (waitingAnimationFinished)
        {
            Debug.LogWarning("Can't PopPanel because waitingAnimationFinished is true");
            return;
        }

        if (panelList.Count <= 1)
        {
            return;
        }
        panelRaycaster.enabled = false;
        EventSystem.current.SetSelectedGameObject(null);

        lastAnimationFinished    = false;
        currentAnimationFinished = false;
        popPanel = true;
        BasePanel closingPanel  = panelList[panelList.Count - 1];
        BasePanel enteringPanel = null;

        if (panelList.Count > 1)
        {
            enteringPanel = panelList[panelList.Count - 2];
            enteringPanel.gameObject.SetActive(true);
            panelList.RemoveAt(panelList.Count - 1);
        }

        if (enteringPanel == null)
        {
            return;
        }
        lastPanel    = closingPanel;
        currentPanel = enteringPanel;

        if (enteringPanel.managedAnimation)
        {
            try
            {
                enteringPanel.OnBeforeEnter();
            }
            catch (Exception e)
            {
                Debug.Log(e.Message);
                Debug.Log(e.StackTrace);
            }
            PlayResumeAnimation(enteringPanel, closingPanel);
        }
        else
        {
            if (closingPanel.managedAnimation)
            {
            }
        }
        try
        {
            closingPanel.OnBeforeExit();
        }
        catch (Exception e)
        {
            Debug.Log(e.Message);
            Debug.Log(e.StackTrace);
        }
        PlayCloseAnimation(closingPanel);
    }