OnShow() public method

public OnShow ( ) : void
return void
Esempio n. 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類型有問題,請檢測類型");
        }
    }
Esempio n. 2
0
    public T OpenUI <T>() where T : UIPanelBase
    {
        System.Type type = typeof(T);

        GameObject prefab = ResourcesMgr.Instance.LoadUIPrefab(type.ToString());

        if (type.IsSubclassOf(typeof(UIWindow)))
        {
            GameObject go  = Instantiate(prefab, Vector3.zero, Quaternion.identity, wndParent);
            UIWindow   wnd = go.GetComponent <UIWindow>();
            wnd.OnCreate();
            //创建新的主界面时,删除所有界面
            if (wnd.isMain)
            {
                while (windowsStack.Count > 0)
                {
                    UIWindow temp = windowsStack.Pop();
                    temp.OnDispose();
                    Destroy(temp.gameObject);
                }
            }
            else if (windowsStack.Count > 0)
            {
                UIWindow temp = windowsStack.Peek();
                temp.OnHide();
                temp.gameObject.SetActive(false);
            }
            wnd.OnShow();
            windowsStack.Push(wnd);
            return(wnd as T);
        }
        else if (type.IsSubclassOf(typeof(UIDialog)))
        {
            GameObject go  = Instantiate(prefab, Vector3.zero, Quaternion.identity, dlgParent);
            UIDialog   dlg = go.GetComponent <UIDialog>();
            dlg.OnCreate();
            dlg.OnShow();
            dialogsStack.Push(dlg);
            return(dlg as T);
        }
        else
        {
            Debug.LogError("打開的UI類型有問題,請檢測類型");
            return(null);
        }
    }