예제 #1
0
        /// <summary>
        /// 打开UI
        /// </summary>
        /// <param name="UIName">UI名</param>
        /// <param name="callback">动画播放完毕回调</param>
        /// <param name="objs">回调传参</param>`
        /// <returns>返回打开的UI</returns>
        public static UIWindowBase OpenUIWindow(string UIName, UICallBack callback = null, params object[] objs)
        {
            UIWindowBase UIbase = GetHideUI(UIName);

            if (UIbase == null)
            {
                UIbase = CreateUIWindow(UIName);
            }

            RemoveHideUI(UIbase);
            AddUI(UIbase);

            UIStackManager.OnUIOpen(UIbase);
            UILayerManager.SetLayer(UIbase);      //设置层级

            UIbase.windowStatus = UIWindowBase.WindowStatus.OpenAnim;

            UISystemEvent.Dispatch(UIbase, UIEvent.OnOpen);  //派发OnOpen事件
            try
            {
                UIbase.OnOpen();
            }
            catch (Exception e)
            {
                Debug.LogError(UIName + " OnOpen Exception: " + e.ToString());
            }

            UISystemEvent.Dispatch(UIbase, UIEvent.OnOpened);     //派发OnOpened事件

            UIAnimManager.StartEnterAnim(UIbase, callback, objs); //播放动画
            return(UIbase);
        }
예제 #2
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);
        }