コード例 #1
0
        public void DestroyUI(CUIWindowBase UI)
        {
            Debug.Log("UIManager DestroyUI " + UI.name);

            CUIManagerHelper.RemoveUIFromCache(UI, HiddenDict);
            CUIManagerHelper.RemoveUIFromCache(UI, ActiveDict);

            Destroy(UI.gameObject);
        }
コード例 #2
0
        private void InternalCloseUI(CUIWindowBase window, params object[] objs)
        {
            try
            {
                window.OnClose();
            }
            catch (Exception e)
            {
                Debug.LogError(window.UIName + " OnClose Exception: " + e.ToString());
            }

            StackManager.OnUIClose(window);
            CUIManagerHelper.AddUIToCache(window, HiddenDict);
        }
コード例 #3
0
        /// <summary>
        /// 根据类型关闭一个ui
        /// </summary>
        public void CloseUI <T>(bool isPlayAnim = true, UICallBack callback = null, params object[] objs)
            where T : CUIWindowBase
        {
            string        winName = typeof(T).Name;
            CUIWindowBase window  = CUIManagerHelper.GetUIFromCache(winName, ActiveDict);

            if (window == null)
            {
                Debug.LogError("CloseUIWindow Error UI ->" + winName + "<-  not Exist!");
                return;
            }

            CloseUI(window, isPlayAnim, callback, objs);
        }
コード例 #4
0
        public void OpenUI <T>(UICallBack callback = null, params object[] objs) where T : CUIWindowBase
        {
            string        winName = typeof(T).Name;
            CUIWindowBase window  = CUIManagerHelper.GetUIFromCache(winName, HiddenDict);

            if (window == null)
            {
                CreateUI <T>(go =>
                {
                    window = go.GetComponent <T>();
                    InternalOpenUI(window, callback, objs);
                });
                return;
            }

            InternalOpenUI(window, callback, objs);
        }
コード例 #5
0
        private void InternalCreateUI <T>(GameObject go) where T : CUIWindowBase
        {
            string        winName = typeof(T).Name;
            CUIWindowBase window  = go.GetComponent <CUIWindowBase>();

            try
            {
                int id = CUIManagerHelper.GetUIIDFromCache(winName, ActiveDict);
                window.Init(id);
                window.OnCreated();
            }
            catch (Exception e)
            {
                Debug.LogError("OnInit Exception: " + e.ToString());
            }

            window.OnHide();
            CUIManagerHelper.AddUIToCache(window, HiddenDict);
            LayerManager.SetLayer(window);             //设置层级
        }
コード例 #6
0
        private void InternalOpenUI(CUIWindowBase window, UICallBack callback, params object[] objs)
        {
            if (window == null)
            {
                throw new Exception("UIManager: InternalOpenUI window is null");
            }

            CUIManagerHelper.RemoveUIFromCache(window, HiddenDict);
            CUIManagerHelper.AddUIToCache(window, ActiveDict);

            StackManager.OnUIOpen(window);
            try
            {
                window.OnOpen(objs);
            }
            catch (Exception e)
            {
                Debug.LogError(window.UIName + " OnOpen Exception: " + e);
            }

            AnimManager.StartEnterAnim(window, callback);             //播放动画
        }
コード例 #7
0
        /// <summary>
        /// 关闭传入的ui实例
        /// </summary>
        public void CloseUI(CUIWindowBase window, bool isPlayAnim = true, UICallBack callback = null,
                            params object[] objs)
        {
            CUIManagerHelper.RemoveUIFromCache(window, ActiveDict);

            if (callback != null)
            {
                callback += InternalCloseUI;
            }
            else
            {
                callback = InternalCloseUI;
            }

            //不播放动画直接调用回调
            if (!isPlayAnim)
            {
                callback(window, objs);
                return;
            }

            AnimManager.StartExitAnim(window, callback);
        }
コード例 #8
0
 public void DestroyAllUI()
 {
     CUIManagerHelper.DestroyUIInCache(ActiveDict);
     CUIManagerHelper.DestroyUIInCache(HiddenDict);
 }
コード例 #9
0
        public CUIWindowBase HideUI(string winName)
        {
            CUIWindowBase ui = CUIManagerHelper.GetUIFromCache(winName, ActiveDict);

            return(HideUI(ui));
        }
コード例 #10
0
        public CUIWindowBase ShowUI(string viewName)
        {
            CUIWindowBase ui = CUIManagerHelper.GetUIFromCache(viewName, ActiveDict);

            return(RevealUI(ui));
        }