/// <summary> /// 预加载非常驻UI /// </summary> public void PreloadingTemporaryUI <T>() where T : UILogicTemporary { if (_UIs.ContainsKey(typeof(T))) { UILogic ui = _UIs[typeof(T)]; 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), _temporaryPanel, null, (obj) => { ui.UIEntity = obj; ui.OnInit(); }, true); } } else { GlobalTools.LogError("预加载UI失败:UI对象 " + typeof(T).Name + " 并未存在!"); } }
/// <summary> /// 预加载非常驻UI /// </summary> /// <param name="type">非常驻UI逻辑类</param> public void PreloadingTemporaryUI(Type type) { if (_worldUIs.ContainsKey(type)) { UILogic ui = _worldUIs[type]; if (!ui.IsCreated) { Main.m_Resource.LoadPrefab(new PrefabInfo(type.GetCustomAttribute <UIResourceAttribute>()), _worldTemporaryPanel, null, (obj) => { ui.UIEntity = obj; ui.OnInit(); }, true); } } else { GlobalTools.LogError(string.Format("预加载UI失败:UI对象 {0} 并未存在!", type.Name)); } }
/// <summary> /// 预加载常驻UI /// </summary> /// <param name="type">常驻UI逻辑类</param> public void PreloadingResidentUI(Type type) { if (_worldUIs.ContainsKey(type)) { UILogic ui = _worldUIs[type]; if (!ui.IsCreated) { Main.m_Resource.LoadPrefab(new PrefabInfo(type.GetCustomAttribute <UIResourceAttribute>()), _worldResidentPanel, null, (obj) => { ui.UIEntity = obj; ui.UIEntity.SetLayerIncludeChildren(_worldUIRoot.gameObject.layer); ui.OnInit(); }, true); } } else { GlobalTools.LogError(string.Format("预加载UI失败:UI对象 {0} 并未存在!", type.Name)); } }
/// <summary> /// 预加载非常驻UI /// </summary> /// <param name="type">非常驻UI逻辑类</param> public void PreloadingTemporaryUI(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) { Main.m_Resource.LoadPrefab(new PrefabInfo(attribute), _overlayTemporaryPanel, null, (obj) => { ui.UIEntity = obj; ui.OnInit(); }, true); } } 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) { Main.m_Resource.LoadPrefab(new PrefabInfo(attribute), _cameraTemporaryPanel, null, (obj) => { ui.UIEntity = obj; ui.OnInit(); }, true); } } else { GlobalTools.LogError(string.Format("预加载UI失败:UI对象 {0} 并未存在!", type.Name)); } break; case UIType.World: if (_worldUIs.ContainsKey(attribute.WorldUIDomainName)) { _worldUIs[attribute.WorldUIDomainName].PreloadingTemporaryUI(type); } else { GlobalTools.LogError(string.Format("预加载UI失败:UI对象 {0} 的域 {1} 并未存在!", type.Name, attribute.WorldUIDomainName)); } break; } } }