예제 #1
0
        private BaseUI LoadUI(string UIName)
        {
            string     uiPath;
            GameObject UIPrefabs = null;
            BaseUI     baseUI    = null;

            UIPaths.TryGetValue(UIName, out uiPath);
            if (!string.IsNullOrEmpty(uiPath))
            {
                UIPrefabs = ResourcesMgr.GetInstance().LoadAsset(uiPath, false);
            }

            if (transformRoot != null && UIPrefabs != null)
            {
                baseUI = UIPrefabs.GetComponent <BaseUI>();
                if (baseUI == null)
                {
                    return(null);
                }

                switch (baseUI.curUIType.type)
                {
                case UIFormType.Normal:
                    UIPrefabs.transform.SetParent(transformNormal, false);
                    break;

                case UIFormType.Fixed:
                    UIPrefabs.transform.SetParent(transformFixed, false);
                    break;

                case UIFormType.PopUp:
                    UIPrefabs.transform.SetParent(transformPopUp, false);
                    break;
                }

                UIPrefabs.SetActive(true);
                cacheUIs.Add(UIName, baseUI);
                return(baseUI);
            }
            return(null);
        }
예제 #2
0
        void PushUIToStack(string UIName)
        {
            BaseUI baseUI;

            //判断栈中是否有其他的窗体,有则冻结
            if (staUIs.Count > 0)
            {
                BaseUI topUI = staUIs.Peek();
                topUI.Freeze();
            }
            //判断UI所有窗体 是否有指定的UI窗体 有就处理
            cacheUIs.TryGetValue(UIName, out baseUI);
            if (baseUI != null)
            {
                baseUI.ActivateTrue();
                //把指定UI窗体,入栈
                staUIs.Push(baseUI);
            }
            else
            {
                Debug.Log($"baseUI==null,请确认窗口是否有BaseUI脚本,参数:{UIName}");
            }
        }