From 863f70d16f20535a5207c2799f6634b1f0fb6d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=93=AE?= <834207172@qq.com> Date: Fri, 29 Aug 2025 11:01:03 +0800 Subject: [PATCH] 1 --- Assets/06.UIFarme/RunTime/Base/BasePanel.cs | 6 ++- .../06.UIFarme/RunTime/Manager/PanelSystem.cs | 52 ++++++++++++------- Assets/06.UIFarme/package.json | 2 +- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/Assets/06.UIFarme/RunTime/Base/BasePanel.cs b/Assets/06.UIFarme/RunTime/Base/BasePanel.cs index fdb0641..3f22a7f 100644 --- a/Assets/06.UIFarme/RunTime/Base/BasePanel.cs +++ b/Assets/06.UIFarme/RunTime/Base/BasePanel.cs @@ -10,6 +10,10 @@ namespace Stary.Evo.UIFarme { public interface IBasePanel : IController { + /// + /// UI信息 + /// + string UIName { get; set; } /// /// 绑定这个面板的实例 /// @@ -68,7 +72,7 @@ namespace Stary.Evo.UIFarme /// /// UI信息 /// - public string UIPath { get; set; } + public string UIName { get; set; } /// /// 面板管理器 diff --git a/Assets/06.UIFarme/RunTime/Manager/PanelSystem.cs b/Assets/06.UIFarme/RunTime/Manager/PanelSystem.cs index 54a162e..cf7b8be 100644 --- a/Assets/06.UIFarme/RunTime/Manager/PanelSystem.cs +++ b/Assets/06.UIFarme/RunTime/Manager/PanelSystem.cs @@ -10,17 +10,17 @@ namespace Stary.Evo.UIFarme /// /// UI的入栈操作,此操作会显示一个面板 /// - Task PushQueue(Transform parent=null,string packageName=null) where T : IBasePanel, new(); + Task PushQueue(string panelName=null,Transform parent = null, string packageName = null) where T : IBasePanel, new(); /// /// UI的入栈操作,此操作会显示一个面板 /// - Task PushStack(Transform parent=null,string packageName=null) where T : IBasePanel, new(); + Task PushStack(string panelName=null,Transform parent = null, string packageName = null) where T : IBasePanel, new(); /// /// 执行面板的出栈操作,此操作会执行面板的OnExit方法 /// - void PopQueue() where T : IBasePanel, new(); + void PopQueue(string panelName=null) where T : IBasePanel, new(); /// /// 执行面板的出栈操作,此操作会执行面板的OnExit方法 @@ -31,6 +31,7 @@ namespace Stary.Evo.UIFarme /// 面板全部出栈此操作会执行面板的OnExit方法 /// void PopAll(); + /// /// 事件发送 /// @@ -54,8 +55,10 @@ namespace Stary.Evo.UIFarme /// 事件发送 /// /// - public void SendPanelEvent(TEvent key, Tvlue1 value1, Tvlue2 vlue2, Tvlue3 vlue3) + public void SendPanelEvent(TEvent key, Tvlue1 value1, Tvlue2 vlue2, + Tvlue3 vlue3) where TEvent : IConvertible; + /// /// 返回存储面板实例的字典 /// @@ -99,17 +102,21 @@ namespace Stary.Evo.UIFarme /// /// 非热更模式传null /// - public async Task PushQueue(Transform parent=null,string packageName=null) where T : IBasePanel, new() + public async Task PushQueue(string panelName=null, Transform parent = null, string packageName = null) + where T : IBasePanel, new() { - string panelName = typeof(T).Name; - + if (string.IsNullOrEmpty(panelName)) + { + panelName = typeof(T).Name; + } IBasePanel nextPanel = null; if (!dicUI.ContainsKey(panelName)) { nextPanel = new T(); + nextPanel.UIName = panelName; nextPanel.Initialize(this); nextPanel.SetPanelParent(parent); - GameObject panelGo = await nextPanel.CreatePanel($"Prefabs_{panelName}",packageName); + GameObject panelGo = await nextPanel.CreatePanel($"Prefabs_{panelName}", packageName); ///生成面板后,进行初始化操作 nextPanel.Initialize(panelGo); dicUI.Add(panelName, nextPanel); @@ -138,17 +145,21 @@ namespace Stary.Evo.UIFarme /// /// 非热更模式传null /// - public async Task PushStack(Transform parent=null,string packageName=null) where T : IBasePanel, new() + public async Task PushStack(string panelName=null,Transform parent = null, string packageName = null) where T : IBasePanel, new() { - string panelName = typeof(T).Name; + if (string.IsNullOrEmpty(panelName)) + { + panelName = typeof(T).Name; + } IBasePanel nextPanel = null; if (!dicUI.ContainsKey(panelName)) { nextPanel = new T(); + nextPanel.UIName = panelName; nextPanel.Initialize(this); nextPanel.SetPanelParent(parent); - GameObject panelGo = await nextPanel.CreatePanel($"Prefabs_{panelName}",packageName); + GameObject panelGo = await nextPanel.CreatePanel($"Prefabs_{panelName}", packageName); ///生成面板后,进行初始化操作 nextPanel.Initialize(panelGo); @@ -171,11 +182,14 @@ namespace Stary.Evo.UIFarme nextPanel.OnEnter(); } - - public void PopQueue() where T : IBasePanel, new() + public void PopQueue(string panelName=null) where T : IBasePanel, new() { - string panelName = typeof(T).Name; + if (string.IsNullOrEmpty(panelName)) + { + panelName = typeof(T).Name; + } + for (int i = 0; i < queuePanel.Count; i++) { @@ -211,6 +225,7 @@ namespace Stary.Evo.UIFarme queuePanel.Clear(); } + /// /// 事件发送 /// @@ -226,7 +241,7 @@ namespace Stary.Evo.UIFarme /// public void SendPanelEvent(TEvent key, Tvalue1 value) where TEvent : IConvertible { - this.SendEvent(key,value); + this.SendEvent(key, value); } /// @@ -243,13 +258,14 @@ namespace Stary.Evo.UIFarme /// 事件发送 /// /// - public void SendPanelEvent(TEvent key, Tvlue1 value1, Tvlue2 vlue2, Tvlue3 vlue3) + public void SendPanelEvent(TEvent key, Tvlue1 value1, Tvlue2 vlue2, + Tvlue3 vlue3) where TEvent : IConvertible { this.SendEvent(key, value1, vlue2, vlue3); } - + public Dictionary Get_Dic() { if (dicUI.Count > 0) @@ -274,7 +290,7 @@ namespace Stary.Evo.UIFarme { PopAll(); stackPanel = null; - queuePanel =null; + queuePanel = null; dicUI = null; } } diff --git a/Assets/06.UIFarme/package.json b/Assets/06.UIFarme/package.json index c663fb7..315b56c 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.17", + "version": "1.0.18", "description": "UI模板框架工具", "unity": "2021.3", "unityRelease": "30f1",