Ejemplo n.º 1
0
            /// <summary>
            /// 关闭UI
            /// </summary>
            /// <param name="type">UI逻辑类</param>
            public void CloseUI(Type type)
            {
                if (_worldUIs.ContainsKey(type))
                {
                    UILogic ui = _worldUIs[type];

                    if (!ui.IsCreated)
                    {
                        return;
                    }

                    if (!ui.IsOpened)
                    {
                        return;
                    }

                    ui.UIEntity.SetActive(false);
                    ui.OnClose();
                }
                else
                {
                    GlobalTools.LogError(string.Format("关闭UI失败:UI对象 {0} 并未存在!", type.Name));
                }
            }
Ejemplo n.º 2
0
        /// <summary>
        /// 关闭UI
        /// </summary>
        public void CloseUI <T>() where T : UILogic
        {
            if (_UIs.ContainsKey(typeof(T)))
            {
                UILogic ui = _UIs[typeof(T)];

                if (!ui.IsCreated)
                {
                    return;
                }

                if (!ui.IsOpened)
                {
                    return;
                }

                ui.UIEntity.SetActive(false);
                ui.OnClose();
            }
            else
            {
                GlobalTools.LogError("关闭UI失败:UI对象 " + typeof(T).Name + " 并未存在!");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 关闭UI
        /// </summary>
        /// <param name="type">UI逻辑类</param>
        public void CloseUI(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.UIEntity.SetActive(false);
                        ui.OnClose();
                    }
                    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.UIEntity.SetActive(false);
                        ui.OnClose();
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("关闭UI失败:UI对象 {0} 并未存在!", type.Name));
                    }
                    break;

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