diff --git a/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Base/BasePanel.cs b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Base/BasePanel.cs index 7d098ab..3ec9c26 100644 --- a/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Base/BasePanel.cs +++ b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Base/BasePanel.cs @@ -14,6 +14,7 @@ namespace Stary.Evo.UIFarme /// string UIName { get; set; } + string UIPath { get; } /// /// 绑定这个面板的实例 /// @@ -81,6 +82,8 @@ namespace Stary.Evo.UIFarme /// public string UIName { get; set; } + public abstract string UIPath { get; } + public abstract UITweenType TweenType { get; } /// diff --git a/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Base/BaseRenderPanel.cs b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Base/BaseRenderPanel.cs index c09ed46..b286513 100644 --- a/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Base/BaseRenderPanel.cs +++ b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Base/BaseRenderPanel.cs @@ -13,6 +13,7 @@ namespace Stary.Evo.UIFarme /// string UIName { get; set; } + string UIPath { get; } BaseRenderPanel.UITweenType TweenType { get; set; } /// /// 绑定这个面板的实例 @@ -69,13 +70,15 @@ namespace Stary.Evo.UIFarme /// ///所有UI面板的父类,包含UI面板的状态信息 /// - public class BaseRenderPanel : IBaseRenderPanel + public abstract class BaseRenderPanel : IBaseRenderPanel { /// /// UI信息 /// public virtual string UIName { get; set; } + public abstract string UIPath { get; } + public UITweenType TweenType { get; set; } diff --git a/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Manager/PanelSystem.cs b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Manager/PanelSystem.cs index d41a775..0bb0d2f 100644 --- a/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Manager/PanelSystem.cs +++ b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Manager/PanelSystem.cs @@ -15,19 +15,22 @@ namespace Stary.Evo.UIFarme /// /// UI的入栈操作,此操作会显示一个面板 /// - Task PushQueue(string panelName=null,Transform parent = null, string packageName = null) where T : IBasePanel, new(); + Task PushQueue(string panelName = null, string packageName = null) + where T : IBasePanel, new(); /// /// UI的入栈操作,此操作会显示一个面板 /// - Task PushStack(string panelName=null,Transform parent = null, string packageName = null) where T : IBasePanel, new(); + Task PushStack(string panelName = null, string packageName = null) + where T : IBasePanel, new(); /// /// 执行面板的出栈操作,此操作会执行面板的OnExit方法 /// - void PopQueue(string panelName=null) where T : IBasePanel, new(); + void PopQueue(string panelName = null) where T : IBasePanel, new(); + + void PopQueue(T t, string panelName = null) where T : IBasePanel, new(); - void PopQueue(T t, string panelName=null) where T : IBasePanel, new(); /// /// 执行面板的出栈操作,此操作会执行面板的OnExit方法 /// @@ -102,8 +105,8 @@ namespace Stary.Evo.UIFarme public PanelSystem(IAssetLoader assetLoader) { this.AssetLoader = assetLoader; - } + protected override void OnInit() { stackPanel = new Stack(); @@ -114,27 +117,30 @@ namespace Stary.Evo.UIFarme Debug.LogError("UnityEvo:AssetLoader is null, please set AssetLoader."); } } + /// /// UI的入栈操作,此操作会显示一个面板 /// /// /// 非热更模式传null /// - public async Task PushQueue(string panelName=null, Transform parent = null, string packageName = null) + public async Task PushQueue(string panelName = null, string packageName = null) where T : IBasePanel, new() { - var prefabName = typeof(T).Name; + var prefabName = typeof(T).Name; if (string.IsNullOrEmpty(panelName)) { panelName = typeof(T).Name; } + IBasePanel nextPanel = null; if (!dicUI.ContainsKey(panelName)) { nextPanel = new T(); nextPanel.UIName = panelName; await nextPanel.InitializeAsync(this); - nextPanel.SetPanelParent(parent); + if (!string.IsNullOrEmpty(nextPanel.UIPath)) + nextPanel.SetPanelParent(GameObject.Find(nextPanel.UIPath).transform); GameObject panelGo = await nextPanel.CreatePanel(prefabName, packageName); ///生成面板后,进行初始化操作 await nextPanel.InitializeAsync(panelGo); @@ -164,9 +170,10 @@ namespace Stary.Evo.UIFarme /// /// 非热更模式传null /// - public async Task PushStack(string panelName=null,Transform parent = null, string packageName = null) where T : IBasePanel, new() + public async Task PushStack(string panelName = null, string packageName = null) + where T : IBasePanel, new() { - var prefabName = typeof(T).Name; + var prefabName = typeof(T).Name; if (string.IsNullOrEmpty(panelName)) { panelName = typeof(T).Name; @@ -178,7 +185,8 @@ namespace Stary.Evo.UIFarme nextPanel = new T(); nextPanel.UIName = panelName; await nextPanel.InitializeAsync(this); - nextPanel.SetPanelParent(parent); + if (!string.IsNullOrEmpty(nextPanel.UIPath)) + nextPanel.SetPanelParent(GameObject.Find(nextPanel.UIPath).transform); GameObject panelGo = await nextPanel.CreatePanel(prefabName, packageName); ///生成面板后,进行初始化操作 await nextPanel.InitializeAsync(panelGo); @@ -197,16 +205,18 @@ namespace Stary.Evo.UIFarme nextPanel = dicUI[panelName]; } - if(stackPanel.Count > 0) + + if (stackPanel.Count > 0) { stackPanel.Peek().OnExit(); } + stackPanel.Push(nextPanel); nextPanel.OnEnter(); } - public void PopQueue(string panelName=null) where T : IBasePanel, new() + public void PopQueue(string panelName = null) where T : IBasePanel, new() { if (string.IsNullOrEmpty(panelName)) { diff --git a/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Manager/SpriteRendererSystem.cs b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Manager/SpriteRendererSystem.cs index ab5e9b2..1c217d0 100644 --- a/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Manager/SpriteRendererSystem.cs +++ b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Manager/SpriteRendererSystem.cs @@ -12,22 +12,16 @@ namespace Stary.Evo.UIFarme /// IAssetLoader AssetLoader { get; set; } - /// - /// UI的入栈操作,此操作会显示一个面板 - /// - Task PushQueue(string prefabName, string packageName = null, Transform parent = null,BaseRenderPanel.UITweenType tweenType = BaseRenderPanel.UITweenType.Fade); - - - Task PushQueue(string packageName = null, Transform parent = null,BaseRenderPanel.UITweenType tweenType = BaseRenderPanel.UITweenType.Fade) + Task PushQueue(string packageName = null, + BaseRenderPanel.UITweenType tweenType = BaseRenderPanel.UITweenType.Fade) where T : IBaseRenderPanel, new(); - Task PushStack(string prefabName, string packageName = null, Transform parent = null); /// /// UI的入栈操作,此操作会显示一个面板 /// - Task PushStack(Transform parent = null, string packageName = null) where T : IBaseRenderPanel, new(); + Task PushStack(string packageName = null) where T : IBaseRenderPanel, new(); /// /// 执行面板的出栈操作,此操作会执行面板的OnExit方法 @@ -37,9 +31,11 @@ namespace Stary.Evo.UIFarme /// /// 执行面板的出栈操作,此操作会执行面板的OnExit方法 /// - void PopQueue(string panelName,BaseRenderPanel.UITweenType tweenType = BaseRenderPanel.UITweenType.Fade); + void PopQueue(string panelName, BaseRenderPanel.UITweenType tweenType = BaseRenderPanel.UITweenType.Fade); + + void PopQueue(BaseRenderPanel.UITweenType tweenType = BaseRenderPanel.UITweenType.Fade) + where T : IBaseRenderPanel, new(); - void PopQueue(BaseRenderPanel.UITweenType tweenType = BaseRenderPanel.UITweenType.Fade) where T : IBaseRenderPanel, new(); /// /// 面板全部出栈此操作会执行面板的OnExit方法 /// @@ -110,6 +106,7 @@ namespace Stary.Evo.UIFarme { this.AssetLoader = assetLoader; } + protected override void OnInit() { stackPanel = new Stack(); @@ -121,44 +118,6 @@ namespace Stary.Evo.UIFarme } } - /// - /// UI的入栈操作,此操作会显示一个面板 - /// - /// - /// 非热更模式传null - /// - public async Task PushQueue(string prefabName, string packageName = null, Transform parent = null,BaseRenderPanel.UITweenType tweenType = BaseRenderPanel.UITweenType.Fade) - { - IBaseRenderPanel nextPanel = null; - if (!dicUI.ContainsKey(prefabName)) - { - nextPanel = new BaseRenderPanel(); - nextPanel.UIName = prefabName; - await nextPanel.InitializeAsync(this); - nextPanel.SetPanelParent(parent); - nextPanel.TweenType = tweenType; - GameObject panelGo = await nextPanel.CreatePanel(packageName, prefabName); - ///生成面板后,进行初始化操作 - await nextPanel.InitializeAsync(panelGo); - dicUI.Add(prefabName, nextPanel); - } - else - { - for (int i = 0; i < queuePanel.Count; i++) - { - if (queuePanel[i].GetType().Name == prefabName) - { - return; - } - } - - nextPanel = dicUI[prefabName]; - } - - queuePanel.Add(nextPanel); - nextPanel.OnEnter(); - //TOOD - } /// /// UI的入栈操作,此操作会显示一个面板 @@ -166,7 +125,8 @@ namespace Stary.Evo.UIFarme /// /// 非热更模式传null /// - public async Task PushQueue(string packageName = null, Transform parent = null,BaseRenderPanel.UITweenType tweenType = BaseRenderPanel.UITweenType.Fade) + public async Task PushQueue(string packageName = null, + BaseRenderPanel.UITweenType tweenType = BaseRenderPanel.UITweenType.Fade) where T : IBaseRenderPanel, new() { var prefabName = typeof(T).Name; @@ -176,7 +136,8 @@ namespace Stary.Evo.UIFarme { nextPanel = new T(); await nextPanel.InitializeAsync(this); - nextPanel.SetPanelParent(parent); + if (!string.IsNullOrEmpty(nextPanel.UIPath)) + nextPanel.SetPanelParent(GameObject.Find(nextPanel.UIPath).transform); nextPanel.TweenType = tweenType; GameObject panelGo = await nextPanel.CreatePanel(packageName, nextPanel.UIName); ///生成面板后,进行初始化操作 @@ -208,50 +169,7 @@ namespace Stary.Evo.UIFarme /// /// 非热更模式传null /// - public async Task PushStack(string prefabName, string packageName = null, Transform parent = null) - { - IBaseRenderPanel nextPanel = null; - if (!dicUI.ContainsKey(prefabName)) - { - nextPanel = new BaseRenderPanel(); - nextPanel.UIName = prefabName; - await nextPanel.InitializeAsync(this); - nextPanel.SetPanelParent(parent); - GameObject panelGo = await nextPanel.CreatePanel(packageName, prefabName); - ///生成面板后,进行初始化操作 - await nextPanel.InitializeAsync(panelGo); - - dicUI.Add(prefabName, nextPanel); - } - else - { - foreach (var panel in stackPanel) - { - if (panel.GetType().Name == prefabName) - { - return; - } - } - - nextPanel = dicUI[prefabName]; - } - - if (stackPanel.Count > 0) - { - stackPanel.Peek().OnExit(); - } - - stackPanel.Push(nextPanel); - nextPanel.OnEnter(); - } - - /// - /// UI的入栈操作,此操作会显示一个面板 - /// - /// - /// 非热更模式传null - /// - public async Task PushStack(Transform parent = null, string packageName = null) + public async Task PushStack(string packageName = null) where T : IBaseRenderPanel, new() { var prefabName = typeof(T).Name; @@ -265,7 +183,8 @@ namespace Stary.Evo.UIFarme { nextPanel = new T(); await nextPanel.InitializeAsync(this); - nextPanel.SetPanelParent(parent); + if (!string.IsNullOrEmpty(nextPanel.UIPath)) + nextPanel.SetPanelParent(GameObject.Find(nextPanel.UIPath).transform); GameObject panelGo = await nextPanel.CreatePanel(packageName, nextPanel.UIName); ///生成面板后,进行初始化操作 await nextPanel.InitializeAsync(panelGo); @@ -294,11 +213,11 @@ namespace Stary.Evo.UIFarme nextPanel.OnEnter(); } - public void PopQueue(string panelName,BaseRenderPanel.UITweenType tweenType = BaseRenderPanel.UITweenType.Fade) + public void PopQueue(string panelName, BaseRenderPanel.UITweenType tweenType = BaseRenderPanel.UITweenType.Fade) { for (int i = 0; i < queuePanel.Count; i++) { - if (queuePanel[i].UIName == panelName) + if (queuePanel[i].UIName == panelName) { queuePanel[i].TweenType = tweenType; queuePanel[i].OnExit(); @@ -306,7 +225,9 @@ namespace Stary.Evo.UIFarme } } } - public void PopQueue(BaseRenderPanel.UITweenType tweenType = BaseRenderPanel.UITweenType.Fade) where T : IBaseRenderPanel, new() + + public void PopQueue(BaseRenderPanel.UITweenType tweenType = BaseRenderPanel.UITweenType.Fade) + where T : IBaseRenderPanel, new() { for (int i = 0; i < queuePanel.Count; i++) { @@ -318,6 +239,7 @@ namespace Stary.Evo.UIFarme } } } + public void PopStack() { if (stackPanel.Count > 0) diff --git a/Assets/00.StaryEvo/package.json b/Assets/00.StaryEvo/package.json index 2351919..ab380b7 100644 --- a/Assets/00.StaryEvo/package.json +++ b/Assets/00.StaryEvo/package.json @@ -1,6 +1,6 @@ { "name": "com.staryevo.main", - "version": "2.1.17", + "version": "2.1.18", "displayName": "00.StaryEvo", "description": "This is an Framework package(后台服务器版本,端口9527)", "unity": "2021.3", diff --git a/Assets/00.StaryEvoTools/Runtime/VideoSystemPanel/VideoPanel.cs b/Assets/00.StaryEvoTools/Runtime/VideoSystemPanel/VideoPanel.cs index cf43e0a..4e75d7e 100644 --- a/Assets/00.StaryEvoTools/Runtime/VideoSystemPanel/VideoPanel.cs +++ b/Assets/00.StaryEvoTools/Runtime/VideoSystemPanel/VideoPanel.cs @@ -31,6 +31,7 @@ public class VideoPanel : BasePanel } + public override string UIPath => ""; public override UITweenType TweenType => UITweenType.Fade; public override void Initialize(GameObject panelGo) diff --git a/Assets/00.StaryEvoTools/package.json b/Assets/00.StaryEvoTools/package.json index 17f74c1..b140a01 100644 --- a/Assets/00.StaryEvoTools/package.json +++ b/Assets/00.StaryEvoTools/package.json @@ -1,6 +1,6 @@ { "name": "com.staryevo.tools", - "version": "1.5.0", + "version": "1.5.1", "displayName": "00.StaryEvo.Tools", "description": "This is an Framework package(后台服务器版本,端口9527)", "unity": "2021.3",