Пример #1
0
        static void AddUI(UIWindowBase UI)
        {
            if (!showUIList.ContainsKey(UI.name))
            {
                showUIList.Add(UI.name, new List <UIWindowBase>());
            }

            showUIList[UI.name].Add(UI);

            UI.Show();
        }
Пример #2
0
        static void AddHideUI(UIWindowBase UI)
        {
            if (!hideUIList.ContainsKey(UI.name))
            {
                hideUIList.Add(UI.name, new List <UIWindowBase>());
            }

            hideUIList[UI.name].Add(UI);

            UI.Hide();
        }
Пример #3
0
        //public static UIBase GetUIBaseByEventKey(string eventKey)
        //{
        //    string UIkey = eventKey.Split('.')[0];
        //    string[] keyArray = UIkey.Split('_');

        //    string uiEventKey = "";

        //    UIBase uiTmp = null;
        //    for (int i = 0; i < keyArray.Length; i++)
        //    {
        //        if (i == 0)
        //        {
        //            uiEventKey = keyArray[0];
        //            uiTmp = GetUIWindowByEventKey(uiEventKey);
        //        }
        //        else
        //        {
        //            uiEventKey += "_" + keyArray[i];
        //            uiTmp = uiTmp.GetItemByKey(uiEventKey);
        //        }

        //        Debug.Log("uiEventKey " + uiEventKey);
        //    }

        //    return uiTmp;
        //}

        //static Regex uiKey = new Regex(@"(\S+)\d+");

        //static UIWindowBase GetUIWindowByEventKey(string eventKey)
        //{
        //    string UIname = uiKey.Match(eventKey).Groups[1].Value;

        //    if (!s_UIs.ContainsKey(UIname))
        //    {
        //        throw new Exception("UIManager: GetUIWindowByEventKey error dont find UI name: ->" + eventKey + "<-  " + UIname);
        //    }

        //    List<UIWindowBase> list = s_UIs[UIname];
        //    for (int i = 0; i < list.Count; i++)
        //    {
        //        if (list[i].UIEventKey == eventKey)
        //        {
        //            return list[i];
        //        }
        //    }

        //    throw new Exception("UIManager: GetUIWindowByEventKey error dont find UI name: ->" + eventKey + "<-  " + UIname);
        //}

        static bool GetIsExits(UIWindowBase UI)
        {
            if (!showUIList.ContainsKey(UI.name))
            {
                return(false);
            }
            else
            {
                return(showUIList[UI.name].Contains(UI));
            }
        }
Пример #4
0
        public void SetLayer(UIWindowBase ui, string cameraKey = null)
        {
            UICameraData data = GetUICameraDataByKey(cameraKey);

            if (cameraKey == null)
            {
                data = GetUICameraDataByKey(ui.cameraKey);
            }
            else
            {
                data = GetUICameraDataByKey(cameraKey);
            }

            RectTransform rt = ui.GetComponent <RectTransform>();

            switch (ui.m_UIType)
            {
            case UIType.GameUI: ui.transform.SetParent(data.m_GameUILayerParent); break;

            case UIType.Fixed: ui.transform.SetParent(data.m_FixedLayerParent); break;

            case UIType.Normal:
                ui.transform.SetParent(data.m_NormalLayerParent);
                break;

            case UIType.TopBar: ui.transform.SetParent(data.m_TopbarLayerParent); break;

            case UIType.Upper: ui.transform.SetParent(data.m_UpperParent); break;

            case UIType.PopUp: ui.transform.SetParent(data.m_PopUpLayerParent); break;
            }

            rt.localScale = Vector3.one;
            rt.sizeDelta  = Vector2.zero;

            if (ui.m_UIType != UIType.GameUI)
            {
                rt.anchorMin = Vector2.zero;
                rt.anchorMax = Vector3.one;

                rt.sizeDelta = Vector2.zero;
                rt.transform.localPosition = new Vector3(0, 0, ui.m_PosZ);
                rt.anchoredPosition3D      = new Vector3(0, 0, ui.m_PosZ);
                rt.SetAsLastSibling();
            }
            else
            {
                Vector3 lp = rt.transform.localPosition;
                lp.z = 0;
                rt.transform.localPosition = lp;
            }
        }
Пример #5
0
        public static void CloseUIWindow(string UIname, bool isPlayAnim = false, UICallBack callback = null, params object[] objs)
        {
            UIWindowBase ui = GetUI(UIname);

            if (ui == null)
            {
                Debug.LogError("CloseUIWindow Error UI ->" + UIname + "<-  not Exist!");
            }
            else
            {
                CloseUIWindow(GetUI(UIname), isPlayAnim, callback, objs);
            }
        }
Пример #6
0
        public void OnUIClose(UIWindowBase ui)
        {
            switch (ui.m_UIType)
            {
            case UIType.Fixed: m_fixedStack.Remove(ui); break;

            case UIType.Normal: m_normalStack.Remove(ui); break;

            case UIType.PopUp: m_popupStack.Remove(ui); break;

            case UIType.TopBar: m_topBarStack.Remove(ui); break;

            case UIType.Upper: m_upperStack.Remove(ui); break;
            }
        }
Пример #7
0
        public static UIWindowBase HideUI(UIWindowBase ui)
        {
            ui.windowStatus = UIWindowBase.WindowStatus.Hide;
            UISystemEvent.Dispatch(ui, UIEvent.OnHide);  //派发OnHide事件

            try
            {
                ui.Hide();
                ui.OnHide();
            }
            catch (Exception e)
            {
                Debug.LogError(ui.UIName + " OnShow Exception: " + e.ToString());
            }

            return(ui);
        }
Пример #8
0
        static void CloseUIWindowCallBack(UIWindowBase UI, params object[] objs)
        {
            UI.windowStatus = UIWindowBase.WindowStatus.Close;
            UISystemEvent.Dispatch(UI, UIEvent.OnClose);  //派发OnClose事件
            try
            {
                UI.OnClose();
            }
            catch (Exception e)
            {
                Debug.LogError(UI.UIName + " OnClose Exception: " + e.ToString());
            }

            UIStackManager.OnUIClose(UI);
            AddHideUI(UI);

            UISystemEvent.Dispatch(UI, UIEvent.OnClosed);  //派发OnClosed事件
        }
Пример #9
0
        //退出动画播放完毕回调
        public void EndExitAnim(UIWindowBase UIbase, UICallBack callBack, params object[] objs)
        {
            UISystemEvent.Dispatch(UIbase, UIEvent.OnCompleteExitAnim);
            UIbase.OnCompleteExitAnim();
            UIbase.windowStatus = UIWindowBase.WindowStatus.Close;

            try
            {
                if (callBack != null)
                {
                    callBack(UIbase, objs);
                }
            }
            catch (Exception e)
            {
                Debug.LogError(e.ToString());
            }
        }
Пример #10
0
        /// <summary>
        /// 派发UI事件
        /// </summary>
        /// <param name="UI"></param>
        /// <param name="UIEvent"></param>
        /// <param name="objs"></param>
        public static void Dispatch(UIWindowBase UI, UIEvent UIEvent, params object[] objs)
        {
            if (UI == null)
            {
                Debug.LogError("Dispatch UI is null!");

                return;
            }

            if (allUIEvents.ContainsKey(UIEvent))
            {
                try
                {
                    if (allUIEvents[UIEvent] != null)
                    {
                        allUIEvents[UIEvent](UI, objs);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("UISystemEvent Dispatch error:" + e.ToString());
                }
            }

            if (singleUIEvents.ContainsKey(UI.name))
            {
                if (singleUIEvents[UI.name].ContainsKey(UIEvent))
                {
                    try
                    {
                        if (singleUIEvents[UI.name][UIEvent] != null)
                        {
                            singleUIEvents[UI.name][UIEvent](UI, objs);
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("UISystemEvent Dispatch error:" + e.ToString());
                    }
                }
            }
        }
Пример #11
0
 /// <summary>
 /// 获取一个隐藏的UI,如果有多个同名UI,则返回最后创建的那一个
 /// </summary>
 /// <param name="UIname">UI名</param>
 /// <returns></returns>
 public static UIWindowBase GetHideUI(string UIname)
 {
     if (!hideUIList.ContainsKey(UIname))
     {
         return(null);
     }
     else
     {
         if (hideUIList[UIname].Count == 0)
         {
             return(null);
         }
         else
         {
             UIWindowBase ui = hideUIList[UIname][hideUIList[UIname].Count - 1];
             //默认返回最后创建的那一个
             return(ui);
         }
     }
 }
Пример #12
0
        static void RemoveHideUI(UIWindowBase UI)
        {
            if (UI == null)
            {
                throw new Exception("UIManager: RemoveUI error l_UI is null: !");
            }

            if (!hideUIList.ContainsKey(UI.name))
            {
                throw new Exception("UIManager: RemoveUI error dont find: " + UI.name + "  " + UI);
            }

            if (!hideUIList[UI.name].Contains(UI))
            {
                throw new Exception("UIManager: RemoveUI error dont find: " + UI.name + "  " + UI);
            }
            else
            {
                hideUIList[UI.name].Remove(UI);
            }
        }
Пример #13
0
        static void RemoveUI(UIWindowBase UI)
        {
            if (UI == null)
            {
                throw new Exception("UIManager: RemoveUI error UI is null: !");
            }

            if (!showUIList.ContainsKey(UI.name))
            {
                throw new Exception("UIManager: RemoveUI error dont find UI name: ->" + UI.name + "<-  " + UI);
            }

            if (!showUIList[UI.name].Contains(UI))
            {
                throw new Exception("UIManager: RemoveUI error dont find UI: ->" + UI.name + "<-  " + UI);
            }
            else
            {
                showUIList[UI.name].Remove(UI);
            }
        }
Пример #14
0
        /// <summary>
        /// 关闭UI
        /// </summary>
        /// <param name="UI">目标UI</param>
        /// <param name="isPlayAnim">是否播放关闭动画</param>
        /// <param name="callback">动画播放完毕回调</param>
        /// <param name="objs">回调传参</param>
        public static void CloseUIWindow(UIWindowBase UI, bool isPlayAnim = false, UICallBack callback = null, params object[] objs)
        {
            RemoveUI(UI);        //移除UI引用
            UI.RemoveAllListener();

            if (isPlayAnim)
            {
                //动画播放完毕删除UI
                if (callback != null)
                {
                    callback += CloseUIWindowCallBack;
                }
                else
                {
                    callback = CloseUIWindowCallBack;
                }
                UI.windowStatus = UIWindowBase.WindowStatus.CloseAnim;
                //UIAnimManager.StartExitAnim(UI, callback, objs);
            }
            else
            {
                CloseUIWindowCallBack(UI, objs);
            }
        }
Пример #15
0
        public static UIWindowBase CreateUIWindow(string UIName)
        {
            //Debug.Log("CreateUIWindow " + UIName);

            GameObject   UItmp        = GameObjectPool.Instance.CreateObject("UI/" + UIName, Vector3.zero, Quaternion.identity, UIManagerGo);
            UIWindowBase UIWIndowBase = UItmp.GetComponent <UIWindowBase>();

            UIWIndowBase.windowStatus = UIWindowBase.WindowStatus.Create;

            try
            {
                UIWIndowBase.InitWindow(GetUIID(UIName));
            }
            catch (Exception e)
            {
                Debug.LogError(UIName + "OnInit Exception: " + e.ToString());
            }

            AddHideUI(UIWIndowBase);

            UILayerManager.SetLayer(UIWIndowBase);      //设置层级

            return(UIWIndowBase);
        }
Пример #16
0
 //开始调用退出动画
 public void StartExitAnim(UIWindowBase UIbase, UICallBack callBack, params object[] objs)
 {
     UISystemEvent.Dispatch(UIbase, UIEvent.OnStartExitAnim);
     StartCoroutine(UIbase.ExitAnim(EndExitAnim, callBack, objs));
 }
Пример #17
0
        public static UIWindowBase HideUI(string UIname)
        {
            UIWindowBase ui = GetUI(UIname);

            return(HideUI(ui));
        }
Пример #18
0
        public static UIWindowBase ShowUI(string UIname)
        {
            UIWindowBase ui = GetUI(UIname);

            return(ShowUI(ui));
        }