diff --git a/UnityGame/Assets/Editor/GameUI/UIComponentExportEditor.cs b/UnityGame/Assets/Editor/GameUI/UIComponentExportEditor.cs index 21cda13..6aa3733 100644 --- a/UnityGame/Assets/Editor/GameUI/UIComponentExportEditor.cs +++ b/UnityGame/Assets/Editor/GameUI/UIComponentExportEditor.cs @@ -135,7 +135,7 @@ public class UIComponentExportEditor : Editor SerializedProperty element = reorderableList.serializedProperty.GetArrayElementAtIndex(i); var filedName = element.FindPropertyRelative("key").stringValue; var typeName = element.FindPropertyRelative("selectedComponentName").stringValue; - sb.AppendLine($" {filedName} = GetGameObject(nameof({filedName})).GetComponent<{typeName}>();"); + sb.AppendLine($" {filedName} = m_ViewExport.GetGameObject(nameof({filedName})).GetComponent<{typeName}>();"); } sb.AppendLine(" }"); sb.AppendLine(" }"); diff --git a/UnityGame/Assets/Editor/GameUI/UIViewExportEditor.cs b/UnityGame/Assets/Editor/GameUI/UIViewExportEditor.cs index a8fd8cb..03812bf 100644 --- a/UnityGame/Assets/Editor/GameUI/UIViewExportEditor.cs +++ b/UnityGame/Assets/Editor/GameUI/UIViewExportEditor.cs @@ -162,7 +162,7 @@ public class UIViewExportEditor : Editor SerializedProperty element = reorderableList.serializedProperty.GetArrayElementAtIndex(i); var filedName = element.FindPropertyRelative("key").stringValue; var typeName = element.FindPropertyRelative("selectedComponentName").stringValue; - sb.AppendLine($" {filedName} = GetGameObject(nameof({filedName})).GetComponent<{typeName}>();"); + sb.AppendLine($" {filedName} = m_ViewExport.GetGameObject(nameof({filedName})).GetComponent<{typeName}>();"); } sb.AppendLine(" }"); sb.AppendLine(" }"); diff --git a/UnityGame/Assets/Scripts/GameLogic/UI/UILogic/UIComponentBase.cs b/UnityGame/Assets/Scripts/GameLogic/UI/UILogic/UIComponentBase.cs index ba6183a..cb26f55 100644 --- a/UnityGame/Assets/Scripts/GameLogic/UI/UILogic/UIComponentBase.cs +++ b/UnityGame/Assets/Scripts/GameLogic/UI/UILogic/UIComponentBase.cs @@ -25,22 +25,5 @@ namespace CreatGame.UI 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 diff --git a/UnityGame/Assets/Scripts/GameLogic/UI/UIViewBase.cs b/UnityGame/Assets/Scripts/GameLogic/UI/UIViewBase.cs index b640545..2550600 100644 --- a/UnityGame/Assets/Scripts/GameLogic/UI/UIViewBase.cs +++ b/UnityGame/Assets/Scripts/GameLogic/UI/UIViewBase.cs @@ -45,18 +45,5 @@ namespace CreatGame.UI DisposeGameObjectCache(); GameObject.Destroy(m_ViewObject); } - - 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 diff --git a/UnityGame/Assets/Scripts/GameTools/UI/UIViewExport.cs b/UnityGame/Assets/Scripts/GameTools/UI/UIViewExport.cs index 1c8fbc0..20abd98 100644 --- a/UnityGame/Assets/Scripts/GameTools/UI/UIViewExport.cs +++ b/UnityGame/Assets/Scripts/GameTools/UI/UIViewExport.cs @@ -13,4 +13,17 @@ public class UIViewExport : MonoBehaviour } public List entries = new List(); + + public GameObject GetGameObject(string name) + { + for (int i = 0; i < entries.Count; i++) + { + if (entries[i].key == name) + { + return entries[i].prefab; + } + } + + return null; + } }