示例#1
0
    protected override void LeoOnDestroy()
    {
        if (mNextWindow.Equals(UIPanelType.NONE))
        {
            return;
        }
        UIViewManagerNGUI.Instance.OpenWindowUI(mNextWindow);
        Leo_UIDepthManager.Instance.CheckOpenedWindows();

        /* 使用上述方法更简洁,不用多次写Leo_WindowUIType.LOGIN了
         * if (mNextWindow.Equals(Leo_WindowUIType.LOGIN))
         * {
         *  GameObject obj = Leo_WindowUIManager.Instance.OpenWindowUI(Leo_WindowUIType.LOGIN);
         * }
         * */
        base.LeoOnDestroy();
    }
示例#2
0
    public GameObject OpenWindowUI(UIPanelType windowType,
                                   //以下2个参数不应该被随便修改,把他们移到Leo_UIWindowBase中统一配置

                                   /* Leo_AnchorPosition pos = Leo_AnchorPosition.CENTER,
                                    * Leo_ShowWindowStyle style = Leo_ShowWindowStyle.NONE,*/bool isUGUI = true, bool isOpenWindow = true)
    {
        GameObject obj = null;

        //判断场景是否已经打开了一个相同场景
        if (mWindowDic.ContainsKey(windowType))
        {
            Debug.Log("已经有一个" + windowType + "在场景中!");
            //temp, Leo solution,UGUI后此方案已过时,新方案为统一设置obj后再统一进行层级管理
            //return mWindowDic[windowType].gameObject;
            obj = mWindowDic[windowType].gameObject;
        }
        else
        {
            //判断当前设置是否是不打开其他窗口
            if (windowType.Equals(UIPanelType.NONE))
            {
                Debug.Log("已设置为不打开窗口!");
                return(null);
            }

            #region UGUI后自行修改
            if (isUGUI)
            {
                //生成一个预制体的精简写法,需保证格式化内容与预制体名一致
                obj = ResourcesManager.Instance.
                      Load(ResourcesManager.ResourceType.UIPanel,
                           string.Format("Panel_{0}UGUI", windowType.ToString().ToLower()), true);
            }
            else
            {
                //生成一个预制体的精简写法,需保证格式化内容与预制体名一致
                obj = ResourcesManager.Instance.
                      Load(ResourcesManager.ResourceType.UI_WINDOW,
                           string.Format("Panel_{0}", windowType.ToString().ToLower()), true);
            }
            #endregion
            #region 使用上述写法后,switch弃用。但需注意Panel_后的内容必须为小写,创建预制体需注意。

            /*
             * switch (windowType)
             * {
             *  case Leo_WindowUIType.LOGIN:
             *      obj = Leo_ResourcesManager.Instance.
             *          Load(Leo_ResourcesManager.ResourceType.UI_WINDOW, "Panel_Login", true);
             *      break;
             *  case Leo_WindowUIType.REG:
             *      obj = Leo_ResourcesManager.Instance.
             *         Load(Leo_ResourcesManager.ResourceType.UI_WINDOW, "Panel_Reg", true);
             *      break;
             * }
             * */
            #endregion
            //把当前类的对象存入字典,方便操作
            //Leo_UIWindowBase windowBase = obj.GetComponent<Leo_UIWindowBase>();
            UIPanelViewBase panelBase = obj.GetComponent <UIPanelViewBase>();
            if (panelBase == null || obj == null)
            {
                return(null);
            }

            //层级管理,后打开的窗口显示在最前方,UGUI后改叫SetOrderInLayer(obj);
            //Leo_UIDepthManager.Instance.SetDepth(obj);

            mWindowDic.Add(windowType, panelBase);
            //设置父类属性,要打开哪个窗口传进去
            panelBase.currentUIType = windowType;
            Transform transParent = null;
            //选择锚点位置
            switch (panelBase.pos)
            {
            case AnchorPosition.CENTER:
                //transParent = Leo_UISceneManager.Instance.currentScene.containerCenter;
                transParent = UIRootController.Instance.currentScene.containerCenter;
                break;

            case AnchorPosition.TOP_LEFT:
                break;

            case AnchorPosition.TOP_RIGHT:
                break;

            case AnchorPosition.BOTTOM_LEFT:
                break;

            case AnchorPosition.BOTTOM_RIGHT:
                break;
            }
            //设置窗口transform参数
            obj.transform.parent        = transParent;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            //生成完先关闭,在下面实现窗口动画时根据需求再开启
            //NGUITools.SetActive(obj, false);
            obj.SetActive(false);
            //ShowWindow(obj, windowBase.style, isOpenWindow);
            //优化后的showWindow,传一个父类对象即可操作,很多属性都在父类中写好了
            ShowWindow(panelBase, isOpenWindow);
        }
        //UGUI层级管理方法,同时优化NGUI时自己的旧写法
        Leo_UIDepthManager.Instance.SetOrderInLayer(obj);
        return(obj);
    }