diff --git a/Assets/06.UIFarme/RunTime/Base/BasePanel.cs b/Assets/06.UIFarme/RunTime/Base/BasePanel.cs index 1cd0539..8cd52d6 100644 --- a/Assets/06.UIFarme/RunTime/Base/BasePanel.cs +++ b/Assets/06.UIFarme/RunTime/Base/BasePanel.cs @@ -9,8 +9,6 @@ namespace Stary.Evo.UIFarme { public interface IBasePanel : IController { - - /// /// 绑定这个面板的实例 /// @@ -50,14 +48,14 @@ namespace Stary.Evo.UIFarme /// /// ui信息 /// - Task CreatePanel(string panelName); + Task CreatePanel(string panelName, string packageName); /// /// 销毁一个Ui对象 /// /// void DestoryUI(); - + void SetPanelParent(Transform parent); } @@ -79,21 +77,20 @@ namespace Stary.Evo.UIFarme /// /// 生成的父物体 /// - protected Transform panelParent{get; private set;} - + protected Transform panelParent { get; private set; } + /// /// 缓存该面板所有的Button,Toggle,Slider,InputField,Dropdown,ScroolBar /// private Dictionary selectableDict; - protected CanvasGroup canvasGroup{get;private set;} - - protected GameObject activePanel{get;private set;} + protected CanvasGroup canvasGroup { get; private set; } + + protected GameObject activePanel { get; private set; } protected BasePanel() { - selectableDict = new Dictionary(); } @@ -148,32 +145,49 @@ namespace Stary.Evo.UIFarme } - public async Task CreatePanel(string panelName) + public async Task CreatePanel(string panelName, string packageName) { if (panelParent == null) { Debug.LogError($"UnityEvo:parent为空,{panelName}无法创建,进程已中断,请检查!!!!!"); return null; } - + if (this.activePanel != null) { return activePanel.gameObject; } - var handle= YooAssets.LoadAssetAsync(panelName); + AssetHandle handle = null; + if (packageName == null) + { + handle = YooAssets.LoadAssetAsync(panelName); + } + else + { + var package= YooAssets.TryGetPackage(packageName); + if (package == null) + { + handle = YooAssets.LoadAssetAsync(panelName); + } + else + { + handle = package.LoadAssetAsync(panelName); + } + } + await handle.Task; - - activePanel = GameObject.Instantiate(handle.AssetObject as GameObject,panelParent); + + activePanel = GameObject.Instantiate(handle.AssetObject as GameObject, panelParent); activePanel.name = this.GetType().Name; - - + + if (!activePanel.GetComponent()) { Debug.LogError($"UnityEvo:panelParent上不存在Canvas组件,{panelName}无法正常运行,进程已中断,请检查!!!!!"); return null; } - + return activePanel; } @@ -204,6 +218,7 @@ namespace Stary.Evo.UIFarme { Debug.LogError($"{this.GetType()}---{name}:在selectableDict不存在"); } + return t as T; } @@ -212,6 +227,4 @@ namespace Stary.Evo.UIFarme return PanelSystem.GetArchitecture(); } } - -} - +} \ No newline at end of file diff --git a/Assets/06.UIFarme/RunTime/Manager/PanelSystem.cs b/Assets/06.UIFarme/RunTime/Manager/PanelSystem.cs index 834735a..e2594ee 100644 --- a/Assets/06.UIFarme/RunTime/Manager/PanelSystem.cs +++ b/Assets/06.UIFarme/RunTime/Manager/PanelSystem.cs @@ -10,12 +10,12 @@ namespace Stary.Evo.UIFarme /// /// UI的入栈操作,此操作会显示一个面板 /// - Task PushQueue(Transform parent) where T : IBasePanel, new(); + Task PushQueue(Transform parent,string packageName=null) where T : IBasePanel, new(); /// /// UI的入栈操作,此操作会显示一个面板 /// - Task PushStack(Transform parent) where T : IBasePanel, new(); + Task PushStack(Transform parent,string packageName=null) where T : IBasePanel, new(); /// /// 执行面板的出栈操作,此操作会执行面板的OnExit方法 @@ -94,7 +94,7 @@ namespace Stary.Evo.UIFarme } - public async Task PushQueue(Transform parent) where T : IBasePanel, new() + public async Task PushQueue(Transform parent,string packageName=null) where T : IBasePanel, new() { string panelName = typeof(T).Name; @@ -104,7 +104,7 @@ namespace Stary.Evo.UIFarme nextPanel = new T(); nextPanel.Initialize(this); nextPanel.SetPanelParent(parent); - GameObject panelGo = await nextPanel.CreatePanel($"Prefabs_{panelName}"); + GameObject panelGo = await nextPanel.CreatePanel($"Prefabs_{panelName}",packageName); ///生成面板后,进行初始化操作 nextPanel.Initialize(panelGo); dicUI.Add(panelName, nextPanel); @@ -127,7 +127,7 @@ namespace Stary.Evo.UIFarme //TOOD } - public async Task PushStack(Transform parent) where T : IBasePanel, new() + public async Task PushStack(Transform parent,string packageName=null) where T : IBasePanel, new() { string panelName = typeof(T).Name; @@ -137,7 +137,7 @@ namespace Stary.Evo.UIFarme nextPanel = new T(); nextPanel.Initialize(this); nextPanel.SetPanelParent(parent); - GameObject panelGo = await nextPanel.CreatePanel(panelName); + GameObject panelGo = await nextPanel.CreatePanel(panelName,packageName); ///生成面板后,进行初始化操作 nextPanel.Initialize(panelGo); diff --git a/Assets/06.UIFarme/package.json b/Assets/06.UIFarme/package.json index 72abd74..a09ae95 100644 --- a/Assets/06.UIFarme/package.json +++ b/Assets/06.UIFarme/package.json @@ -1,7 +1,7 @@ { "name": "com.staryevo.uifarme", "displayName": "06.UIFarme", - "version": "1.0.5", + "version": "1.0.6", "description": "UI模板框架工具", "unity": "2021.3", "unityRelease": "30f1",