Example #1
0
    public void CloseUI(UIPanelBase uiPanel)
    {
        if (uiPanel.GetType().IsSubclassOf(typeof(UIWindow)))
        {
            UIWindow tempWnd = windowsStack.Peek();
            Debug.Log(tempWnd.name);
            if (!(uiPanel as UIWindow).isMain && tempWnd == uiPanel)
            {
                tempWnd = windowsStack.Pop();
                tempWnd.OnDispose();
                Destroy(tempWnd.gameObject);

                tempWnd = windowsStack.Peek();
                tempWnd.gameObject.SetActive(true);
                tempWnd.OnShow();
            }
            else
            {
                Debug.LogError("要关闭的界面不是栈顶元素或是栈底元素");
            }
        }
        else if (uiPanel.GetType().IsSubclassOf(typeof(UIDialog)))
        {
            UIDialog tempDlg = dialogsStack.Peek();

            Debug.Log(tempDlg.gameObject.name + "  " + uiPanel.gameObject.name);

            if (tempDlg == uiPanel)
            {
                tempDlg = dialogsStack.Pop();
                tempDlg.OnDispose();
                Destroy(tempDlg.gameObject);

                if (dialogsStack.Count > 0)
                {
                    tempDlg = dialogsStack.Peek();
                    tempDlg.OnShow();
                }
            }
            else
            {
                Debug.LogError("要关闭的界面不是栈顶元素");
            }
        }
        else
        {
            Debug.LogError("关闭的UI類型有問題,請檢測類型");
        }
    }
Example #2
0
 public void CloseUI(UIPanelBase uiPanel)
 {
     if (uiPanel.GetType().IsSubclassOf(typeof(UIWindow)))
     {
         if (!(uiPanel as UIWindow).isMain && windowsStack.Peek() == uiPanel)
         {
             windowsStack.Pop();
             Destroy(uiPanel.gameObject);
             UIWindow temp = windowsStack.Peek();
             temp.gameObject.SetActive(true);
             temp.OnShow();
         }
         else
         {
             Debug.LogError("要关闭的界面不是栈顶元素或是栈底元素");
         }
     }
     else if (uiPanel.GetType().IsSubclassOf(typeof(UIDialog)))
     {
         if (dialogsStack.Peek() == uiPanel)
         {
             dialogsStack.Pop();
             Destroy(uiPanel.gameObject);
             if (dialogsStack.Count > 0)
             {
                 dialogsStack.Peek().OnShow();
             }
         }
         else
         {
             Debug.LogError("要关闭的界面不是栈顶元素");
         }
     }
     else
     {
         Debug.LogError("关闭的UI類型有問題,請檢測類型");
     }
 }