From 5580b437439e25e4ceb2c9db444f0fa9edb58dc1 Mon Sep 17 00:00:00 2001 From: TongZiGang <754383023@qq.com> Date: Fri, 25 Jul 2025 00:10:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=AF=BC=E5=87=BA=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editor/GameUI/UIComponentExportEditor.cs | 2 +- .../GameLogic/UI/UILogic/UIComponentBase.cs | 36 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/UnityGame/Assets/Editor/GameUI/UIComponentExportEditor.cs b/UnityGame/Assets/Editor/GameUI/UIComponentExportEditor.cs index b609d1a..21cda13 100644 --- a/UnityGame/Assets/Editor/GameUI/UIComponentExportEditor.cs +++ b/UnityGame/Assets/Editor/GameUI/UIComponentExportEditor.cs @@ -113,7 +113,7 @@ public class UIComponentExportEditor : Editor sb.AppendLine("{"); sb.AppendLine($" public partial class {className} : UIComponentBase"); sb.AppendLine(" {"); - sb.AppendLine($" public override string PrefabPath => \"Prefabs/UI/{target.GameObject().name}\";"); + // sb.AppendLine($" public override string PrefabPath => \"Prefabs/UI/{target.GameObject().name}\";"); // 字段定义 diff --git a/UnityGame/Assets/Scripts/GameLogic/UI/UILogic/UIComponentBase.cs b/UnityGame/Assets/Scripts/GameLogic/UI/UILogic/UIComponentBase.cs index ab5f6ce..ba6183a 100644 --- a/UnityGame/Assets/Scripts/GameLogic/UI/UILogic/UIComponentBase.cs +++ b/UnityGame/Assets/Scripts/GameLogic/UI/UILogic/UIComponentBase.cs @@ -7,6 +7,40 @@ namespace CreatGame.UI /// public class UIComponentBase : MonoBehaviour { - + /// + /// 窗口预制件 + /// + protected GameObject m_ComponentObject; + /// + /// 导出脚本 + /// + protected UIViewExport m_ViewExport; + /// + /// 是否加载完成 + /// + public bool IsPreLoad = false; + public virtual void PreLoad(GameObject obj) + { + m_ComponentObject = obj; + m_ViewExport = obj.GetComponent(); + IsPreLoad = true; + } + /// + /// + /// + /// + /// + protected GameObject GetGameObject(string name) + { + for (int i = 0; i < m_ViewExport.entries.Count; i++) + { + if (m_ViewExport.entries[i].key == name) + { + return m_ViewExport.entries[i].prefab; + } + } + + return null; + } } } \ No newline at end of file