Ejemplo n.º 1
0
        /// <summary>
        /// 打开UI,同时记录上一层UI
        /// </summary>
        /// <param name="uIType">UI脚本的类型</param>
        /// <param name="preLayerUI">上层UI脚本的引用</param>
        /// <returns></returns>
        public static FairyGUIBaseUI Open(Type uIType, FairyGUIBaseUI preLayerUI)
        {
            FairyGUIBaseUI t = Game.Scene.GetComponent <FairyGUIComponent>().Create(uIType);

            //     t.preLayerUI = preLayerUI;
            return(t);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 组件销毁执行的析构函数
        /// </summary>
        public override void Dispose()
        {
            if (this.IsDisposed)
            {
                return;
            }

            //清空层级管理容器
            foreach (List <FairyGUIBaseUI> uIList in _LayerDictionary.Values)
            {
                if (uIList == null || uIList.Count <= 0)
                {
                    continue;
                }

                for (int i = uIList.Count - 1; i >= 0; i--)
                {
                    FairyGUIBaseUI uiListItem = uIList[i];
                    if (uiListItem != null && !uiListItem.IsDisposed)
                    {
                        uiListItem.Dispose();
                    }
                }
                uIList.Clear();
            }
            _LayerDictionary.Clear();
            //清空baseUIContainer
            baseUIContainer.Dispose();
            base.Dispose();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 销毁UI,调用UI组件时,会调用dispose同时销毁gui组件
 /// </summary>
 /// <param name="ui"></param>
 public void Destory(FairyGUIBaseUI ui)
 {
     //从层中移除
     _LayerDictionary[ui.UIType].Remove(ui);
     //从脚本容器中移除(会调用dispose)
     baseUIContainer.RemoveComponent(ui.GetType());
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 关闭同层ui.
        /// </summary>
        /// <param name="ui"></param>
        public void DestoryLayer(FairyGUIBaseUI ui)
        {
            List <FairyGUIBaseUI> uIList = _LayerDictionary[ui.UIType];

            if (uIList == null || uIList.Count <= 0)
            {
                return;
            }
            for (int i = uIList.Count - 1; i >= 0; i--)
            {
                FairyGUIBaseUI uiListItem = uIList[i];
                if (uiListItem != null && !uiListItem.IsDisposed)
                {
                    uiListItem.Close();
                }
            }
            uIList.Clear();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 非泛型方法创建UI
        /// </summary>
        /// <param name="uIType"></param>
        /// <returns></returns>
        internal FairyGUIBaseUI Create(Type uIType)
        {
            if (baseUIContainer.IsDisposed)
            {
                baseUIContainer = ComponentFactory.Create <FairyGUIContainer>();
            }

            FairyGUIBaseUI t = baseUIContainer.GetComponent(uIType) as FairyGUIBaseUI;

            if (t == null)
            {
                t      = baseUIContainer.AddComponent(uIType) as FairyGUIBaseUI;
                t.gObj = MonoInstance.Create(t.pakName, t.cmpName);
                //加入到对应层中。
                _LayerDictionary[t.UIType].Add(t);
                ShowLayer();
            }
            t.InitUI();
            return(t);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 清除所有UI
        /// </summary>
        public void DestoryAll()
        {
            foreach (List <FairyGUIBaseUI> uIList in _LayerDictionary.Values)
            {
                if (uIList == null || uIList.Count <= 0)
                {
                    continue;
                }

                for (int i = uIList.Count - 1; i >= 0; i--)
                {
                    FairyGUIBaseUI uiListItem = uIList[i];
                    if (uiListItem != null && !uiListItem.IsDisposed)
                    {
                        uiListItem.Dispose();
                    }
                }
                uIList.Clear();
            }
            baseUIContainer.Dispose();
            ShowLayer();
        }