예제 #1
0
            /// <summary>
            /// 销毁UI
            /// </summary>
            /// <param name="type">UI逻辑类</param>
            public void DestroyUI(Type type)
            {
                if (_worldUIs.ContainsKey(type))
                {
                    UILogic ui = _worldUIs[type];

                    if (!ui.IsCreated)
                    {
                        return;
                    }

                    if (ui.IsOpened)
                    {
                        return;
                    }

                    ui.OnDestroy();
                    Destroy(ui.UIEntity);
                    ui.UIEntity = null;
                }
                else
                {
                    GlobalTools.LogError(string.Format("销毁UI失败:UI对象 {0} 并未存在!", type.Name));
                }
            }
예제 #2
0
        /// <summary>
        /// 销毁UI
        /// </summary>
        public void DestroyUI <T>() where T : UILogic
        {
            if (_UIs.ContainsKey(typeof(T)))
            {
                UILogic ui = _UIs[typeof(T)];

                if (!ui.IsCreated)
                {
                    return;
                }

                if (ui.IsOpened)
                {
                    return;
                }

                ui.OnDestroy();
                Destroy(ui.UIEntity);
                ui.UIEntity = null;
            }
            else
            {
                GlobalTools.LogError("销毁UI失败:UI对象 " + typeof(T).Name + " 并未存在!");
            }
        }
예제 #3
0
            /// <summary>
            /// 销毁域
            /// </summary>
            public void Termination()
            {
                foreach (KeyValuePair <Type, UILogic> ui in _worldUIs)
                {
                    UILogic uiLogic = ui.Value;

                    if (!uiLogic.IsCreated)
                    {
                        return;
                    }

                    uiLogic.OnDestroy();
                    Destroy(uiLogic.UIEntity);
                    uiLogic.UIEntity = null;
                }
                _worldUIs.Clear();

                Destroy(_worldUIRoot.gameObject);
            }
예제 #4
0
        public override void Termination()
        {
            base.Termination();

            foreach (KeyValuePair <Type, UILogic> ui in _UIs)
            {
                UILogic uiLogic = ui.Value;

                if (!uiLogic.IsCreated)
                {
                    return;
                }

                uiLogic.OnDestroy();
                Destroy(uiLogic.UIEntity);
                uiLogic.UIEntity = null;
            }
            _UIs.Clear();
        }
예제 #5
0
        public override void OnTermination()
        {
            base.OnTermination();

            foreach (KeyValuePair <Type, UILogic> ui in _overlayUIs)
            {
                UILogic uiLogic = ui.Value;

                if (!uiLogic.IsCreated)
                {
                    return;
                }

                uiLogic.OnDestroy();
                Destroy(uiLogic.UIEntity);
                uiLogic.UIEntity = null;
            }
            _overlayUIs.Clear();

            foreach (KeyValuePair <Type, UILogic> ui in _cameraUIs)
            {
                UILogic uiLogic = ui.Value;

                if (!uiLogic.IsCreated)
                {
                    return;
                }

                uiLogic.OnDestroy();
                Destroy(uiLogic.UIEntity);
                uiLogic.UIEntity = null;
            }
            _cameraUIs.Clear();

            foreach (KeyValuePair <string, WorldUIDomain> ui in _worldUIs)
            {
                ui.Value.Termination();
            }
            _worldUIs.Clear();
        }
예제 #6
0
        /// <summary>
        /// 销毁UI
        /// </summary>
        /// <param name="type">UI逻辑类</param>
        public void DestroyUI(Type type)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

            if (attribute != null)
            {
                switch (attribute.EntityType)
                {
                case UIType.Overlay:
                    if (_overlayUIs.ContainsKey(type))
                    {
                        UILogic ui = _overlayUIs[type];

                        if (!ui.IsCreated)
                        {
                            return;
                        }

                        if (ui.IsOpened)
                        {
                            return;
                        }

                        ui.OnDestroy();
                        Destroy(ui.UIEntity);
                        ui.UIEntity = null;
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("销毁UI失败:UI对象 {0} 并未存在!", type.Name));
                    }
                    break;

                case UIType.Camera:
                    if (_cameraUIs.ContainsKey(type))
                    {
                        UILogic ui = _cameraUIs[type];

                        if (!ui.IsCreated)
                        {
                            return;
                        }

                        if (ui.IsOpened)
                        {
                            return;
                        }

                        ui.OnDestroy();
                        Destroy(ui.UIEntity);
                        ui.UIEntity = null;
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("销毁UI失败:UI对象 {0} 并未存在!", type.Name));
                    }
                    break;

                case UIType.World:
                    if (_worldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        _worldUIs[attribute.WorldUIDomainName].DestroyUI(type);
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("销毁UI失败:UI对象 {0} 的域 {1} 并未存在!", type.Name, attribute.WorldUIDomainName));
                    }
                    break;
                }
            }
        }