コード例 #1
0
        /// <summary>
        /// 置顶常驻UI
        /// </summary>
        /// <param name="type">常驻UI逻辑类</param>
        public void PlaceTop(Type type)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

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

                        if (!ui.IsOpened)
                        {
                            return;
                        }

                        ui.UIEntity.transform.SetAsLastSibling();
                        ui.OnPlaceTop();
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("置顶UI失败:UI对象 {0} 并未存在!", type.Name));
                    }
                    break;

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

                        if (!ui.IsOpened)
                        {
                            return;
                        }

                        ui.UIEntity.transform.SetAsLastSibling();
                        ui.OnPlaceTop();
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("置顶UI失败:UI对象 {0} 并未存在!", type.Name));
                    }
                    break;

                case UIType.World:
                    if (_worldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        _worldUIs[attribute.WorldUIDomainName].PlaceTop(type);
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("置顶UI失败:UI对象 {0} 的域 {1} 并未存在!", type.Name, attribute.WorldUIDomainName));
                    }
                    break;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 置顶常驻UI
        /// </summary>
        /// <param name="type">常驻UI逻辑类</param>
        public void PlaceTopUI(Type type)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

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

                        if (!ui.IsOpened)
                        {
                            return;
                        }

                        ui.UIEntity.transform.SetAsLastSibling();
                        ui.OnPlaceTop();
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "置顶UI失败:UI对象 " + type.Name + " 并未存在!");
                    }
                    break;

                case UIType.Camera:
                    if (CameraUIs.ContainsKey(type))
                    {
                        UILogicResident ui = CameraUIs[type] as UILogicResident;

                        if (!ui.IsOpened)
                        {
                            return;
                        }

                        ui.UIEntity.transform.SetAsLastSibling();
                        ui.OnPlaceTop();
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "置顶UI失败:UI对象 " + type.Name + " 并未存在!");
                    }
                    break;

                case UIType.World:
                    if (WorldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        WorldUIs[attribute.WorldUIDomainName].PlaceTop(type);
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "置顶UI失败:UI对象 " + type.Name + " 的域 " + attribute.WorldUIDomainName + " 并未存在!");
                    }
                    break;
                }
            }
        }
コード例 #3
0
ファイル: UIManager.cs プロジェクト: yanngu/HTFramework
            /// <summary>
            /// 打开常驻UI
            /// </summary>
            /// <param name="type">常驻UI逻辑类</param>
            /// <param name="entity">UI实体</param>
            /// <param name="args">可选参数</param>
            /// <returns>加载协程</returns>
            public Coroutine OpenResidentUI(Type type, GameObject entity, params object[] args)
            {
                if (_worldUIs.ContainsKey(type))
                {
                    UILogicResident ui = _worldUIs[type] as UILogicResident;

                    if (ui.IsOpened)
                    {
                        return(null);
                    }

                    if (!ui.IsCreated)
                    {
                        if (entity != null)
                        {
                            ui.UIEntity = Instantiate(entity, _worldResidentPanel);
                            ui.UIEntity.SetLayerIncludeChildren(_worldUIRoot.gameObject.layer);
                            ui.UIEntity.transform.SetAsLastSibling();
                            ui.UIEntity.SetActive(true);
                            ui.OnInit();
                            ui.OnOpen(args);
                            ui.OnPlaceTop();
                            return(null);
                        }
                        else
                        {
                            return(Main.m_Resource.LoadPrefab(new PrefabInfo(type.GetCustomAttribute <UIResourceAttribute>()), _worldResidentPanel, null, (obj) =>
                            {
                                ui.UIEntity = obj;
                                ui.UIEntity.SetLayerIncludeChildren(_worldUIRoot.gameObject.layer);
                                ui.UIEntity.transform.SetAsLastSibling();
                                ui.UIEntity.SetActive(true);
                                ui.OnInit();
                                ui.OnOpen(args);
                                ui.OnPlaceTop();
                            }, true));
                        }
                    }
                    else
                    {
                        ui.UIEntity.transform.SetAsLastSibling();
                        ui.UIEntity.SetActive(true);
                        ui.OnOpen(args);
                        ui.OnPlaceTop();
                    }
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.UI, "打开UI失败:UI对象 " + type.Name + " 并未存在!");
                }
                return(null);
            }
コード例 #4
0
        /// <summary>
        /// 置顶常驻UI实体
        /// </summary>
        /// <param name="uILogic">UI逻辑类对象</param>
        private void PlaceTopUIEntity(UILogicResident uILogic)
        {
            if (uILogic == null)
            {
                return;
            }

            if (!uILogic.IsOpened)
            {
                return;
            }

            uILogic.UIEntity.transform.SetAsLastSibling();
            uILogic.OnPlaceTop();
        }
コード例 #5
0
        /// <summary>
        /// 置顶常驻UI
        /// </summary>
        /// <param name="type">常驻UI逻辑类</param>
        public void PlaceTop(Type type)
        {
            if (_worldUIs.ContainsKey(type))
            {
                UILogicResident ui = _worldUIs[type] as UILogicResident;

                if (!ui.IsOpened)
                {
                    return;
                }

                ui.UIEntity.transform.SetAsLastSibling();
                ui.OnPlaceTop();
            }
        }
コード例 #6
0
            /// <summary>
            /// 置顶常驻UI
            /// </summary>
            /// <param name="type">常驻UI逻辑类</param>
            public void PlaceTop(Type type)
            {
                if (_worldUIs.ContainsKey(type))
                {
                    UILogicResident ui = _worldUIs[type] as UILogicResident;

                    if (!ui.IsOpened)
                    {
                        return;
                    }

                    ui.UIEntity.transform.SetAsLastSibling();
                    ui.OnPlaceTop();
                }
                else
                {
                    GlobalTools.LogError(string.Format("置顶UI失败:UI对象 {0} 并未存在!", type.Name));
                }
            }
コード例 #7
0
ファイル: UIManager.cs プロジェクト: yanngu/HTFramework
            /// <summary>
            /// 置顶常驻UI
            /// </summary>
            /// <param name="type">常驻UI逻辑类</param>
            public void PlaceTop(Type type)
            {
                if (_worldUIs.ContainsKey(type))
                {
                    UILogicResident ui = _worldUIs[type] as UILogicResident;

                    if (!ui.IsOpened)
                    {
                        return;
                    }

                    ui.UIEntity.transform.SetAsLastSibling();
                    ui.OnPlaceTop();
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.UI, "置顶UI失败:UI对象 " + type.Name + " 并未存在!");
                }
            }
コード例 #8
0
        /// <summary>
        /// 置顶常驻UI
        /// </summary>
        public void PlaceTop <T>() where T : UILogicResident
        {
            if (_UIs.ContainsKey(typeof(T)))
            {
                UILogicResident ui = _UIs[typeof(T)] as UILogicResident;

                if (!ui.IsOpened)
                {
                    return;
                }

                ui.UIEntity.transform.SetAsLastSibling();
                ui.OnPlaceTop();
            }
            else
            {
                GlobalTools.LogError("置顶UI失败:UI对象 " + typeof(T).Name + " 并未存在!");
            }
        }
コード例 #9
0
        /// <summary>
        /// 打开常驻UI
        /// </summary>
        public void OpenResidentUI <T>(params object[] args) where T : UILogicResident
        {
            if (_UIs.ContainsKey(typeof(T)))
            {
                UILogicResident ui = _UIs[typeof(T)] as UILogicResident;

                if (ui.IsOpened)
                {
                    return;
                }

                if (!ui.IsCreated)
                {
                    object[] atts = typeof(T).GetCustomAttributes(typeof(UIResourceAttribute), false);
                    if (atts.Length != 1)
                    {
                        GlobalTools.LogError("打开UI失败:UI对象 " + typeof(T).Name + " 并未标记UIResourceAttribute特性!");
                        return;
                    }
                    Main.m_Resource.LoadPrefab(new PrefabInfo(atts[0] as UIResourceAttribute), _residentPanel, null, (obj) =>
                    {
                        ui.UIEntity = obj;
                        ui.UIEntity.transform.SetAsLastSibling();
                        ui.UIEntity.SetActive(true);
                        ui.OnInit();
                        ui.OnOpen(args);
                        ui.OnPlaceTop();
                    }, true);
                }
                else
                {
                    ui.UIEntity.transform.SetAsLastSibling();
                    ui.UIEntity.SetActive(true);
                    ui.OnOpen(args);
                    ui.OnPlaceTop();
                }
            }
            else
            {
                GlobalTools.LogError("打开UI失败:UI对象 " + typeof(T).Name + " 并未存在!");
            }
        }
コード例 #10
0
            /// <summary>
            /// 打开常驻UI
            /// </summary>
            /// <param name="type">常驻UI逻辑类</param>
            /// <param name="args">可选参数</param>
            /// <returns>加载协程</returns>
            public Coroutine OpenResidentUI(Type type, params object[] args)
            {
                if (_worldUIs.ContainsKey(type))
                {
                    UILogicResident ui = _worldUIs[type] as UILogicResident;

                    if (ui.IsOpened)
                    {
                        return(null);
                    }

                    if (!ui.IsCreated)
                    {
                        return(Main.m_Resource.LoadPrefab(new PrefabInfo(type.GetCustomAttribute <UIResourceAttribute>()), _worldResidentPanel, null, (obj) =>
                        {
                            ui.UIEntity = obj;
                            ui.UIEntity.SetLayerIncludeChildren(_worldUIRoot.gameObject.layer);
                            ui.UIEntity.transform.SetAsLastSibling();
                            ui.UIEntity.SetActive(true);
                            ui.OnInit();
                            ui.OnOpen(args);
                            ui.OnPlaceTop();
                        }, true));
                    }
                    else
                    {
                        ui.UIEntity.transform.SetAsLastSibling();
                        ui.UIEntity.SetActive(true);
                        ui.OnOpen(args);
                        ui.OnPlaceTop();
                    }
                }
                else
                {
                    GlobalTools.LogError(string.Format("打开UI失败:UI对象 {0} 并未存在!", type.Name));
                }
                return(null);
            }
コード例 #11
0
        /// <summary>
        /// 打开常驻UI
        /// </summary>
        /// <param name="type">常驻UI逻辑类</param>
        /// <param name="args">可选参数</param>
        /// <returns>加载协程</returns>
        public Coroutine OpenResidentUI(Type type, params object[] args)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

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

                        if (ui.IsOpened)
                        {
                            return(null);
                        }

                        if (!ui.IsCreated)
                        {
                            return(CreateOpenUIEntity(attribute, type.FullName, ui, _overlayResidentPanel, args));
                        }
                        else
                        {
                            ui.UIEntity.transform.SetAsLastSibling();
                            ui.UIEntity.SetActive(true);
                            ui.OnOpen(args);
                            ui.OnPlaceTop();
                        }
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "打开UI失败:UI对象 " + type.Name + " 并未存在!");
                    }
                    break;

                case UIType.Camera:
                    if (CameraUIs.ContainsKey(type))
                    {
                        UILogicResident ui = CameraUIs[type] as UILogicResident;

                        if (ui.IsOpened)
                        {
                            return(null);
                        }

                        if (!ui.IsCreated)
                        {
                            return(CreateOpenUIEntity(attribute, type.FullName, ui, _cameraResidentPanel, args));
                        }
                        else
                        {
                            ui.UIEntity.transform.SetAsLastSibling();
                            ui.UIEntity.SetActive(true);
                            ui.OnOpen(args);
                            ui.OnPlaceTop();
                        }
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "打开UI失败:UI对象 " + type.Name + " 并未存在!");
                    }
                    break;

                case UIType.World:
                    if (WorldUIs.ContainsKey(attribute.WorldUIDomainName))
                    {
                        return(WorldUIs[attribute.WorldUIDomainName].OpenResidentUI(type, _defineUIAndEntitys.ContainsKey(type.FullName) ? _defineUIAndEntitys[type.FullName] : null, args));
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.UI, "打开UI失败:UI对象 " + type.Name + " 的域 " + attribute.WorldUIDomainName + " 并未存在!");
                    }
                }
            }
            return(null);
        }
コード例 #12
0
        /// <summary>
        /// 打开常驻UI
        /// </summary>
        /// <param name="type">常驻UI逻辑类</param>
        /// <param name="args">可选参数</param>
        public void OpenResidentUI(Type type, params object[] args)
        {
            UIResourceAttribute attribute = type.GetCustomAttribute <UIResourceAttribute>();

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

                        if (ui.IsOpened)
                        {
                            return;
                        }

                        if (!ui.IsCreated)
                        {
                            Main.m_Resource.LoadPrefab(new PrefabInfo(attribute), _overlayResidentPanel, null, (obj) =>
                            {
                                ui.UIEntity = obj;
                                ui.UIEntity.transform.SetAsLastSibling();
                                ui.UIEntity.SetActive(true);
                                ui.OnInit();
                                ui.OnOpen(args);
                                ui.OnPlaceTop();
                            }, true);
                        }
                        else
                        {
                            ui.UIEntity.transform.SetAsLastSibling();
                            ui.UIEntity.SetActive(true);
                            ui.OnOpen(args);
                            ui.OnPlaceTop();
                        }
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("打开UI失败:UI对象 {0} 并未存在!", type.Name));
                    }
                    break;

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

                        if (ui.IsOpened)
                        {
                            return;
                        }

                        if (!ui.IsCreated)
                        {
                            Main.m_Resource.LoadPrefab(new PrefabInfo(attribute), _cameraResidentPanel, null, (obj) =>
                            {
                                ui.UIEntity = obj;
                                ui.UIEntity.transform.SetAsLastSibling();
                                ui.UIEntity.SetActive(true);
                                ui.OnInit();
                                ui.OnOpen(args);
                                ui.OnPlaceTop();
                            }, true);
                        }
                        else
                        {
                            ui.UIEntity.transform.SetAsLastSibling();
                            ui.UIEntity.SetActive(true);
                            ui.OnOpen(args);
                            ui.OnPlaceTop();
                        }
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("打开UI失败:UI对象 {0} 并未存在!", type.Name));
                    }
                    break;

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