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