Ejemplo n.º 1
0
        public static void Init()
        {
            if (!m_isInit)
            {
                m_isInit = true;

                GameObject instance = GameObject.Find("UIManager");

                if (instance == null)
                {
                    instance = GameObjectPool.Instance.CreateObject("UI/UIManager", Vector3.zero, Quaternion.identity);
                }

                m_uiCamera = instance.GetComponentInChildren <Camera>();
                m_uiCanvas = instance.GetComponentInChildren <Canvas>();

                s_uiManagerGo = instance;

                s_uiLayerManager = instance.GetComponent <UILayerManager>();
                s_uiAnimManager  = instance.GetComponent <UIAnimManager>();
                s_uiStackManager = instance.GetComponent <UIStackManager>();
                s_eventSystem    = instance.GetComponentInChildren <EventSystem>();

                if (Application.isPlaying)
                {
                    DontDestroyOnLoad(instance);
                }
            }
        }
Ejemplo n.º 2
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(objs);
            }
            catch (Exception e)
            {
                Debug.LogError(UIName + " OnOpen Exception: " + e.ToString());
            }

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

            UIAnimManager.StartEnterAnim(UIbase, callback);   //播放动画
            return(UIbase);
        }