From bb82e65ac6149ecbed100d7c84e8fd9effa6ac9e Mon Sep 17 00:00:00 2001 From: TongZiGang <754383023@qq.com> Date: Fri, 25 Jul 2025 00:14:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E4=BB=A3=E7=A0=81=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editor/GameUI/UIComponentExportEditor.cs | 2 +- .../Assets/Editor/GameUI/UIViewExportEditor.cs | 2 +- .../GameLogic/UI/UILogic/UIComponentBase.cs | 17 ----------------- .../Assets/Scripts/GameLogic/UI/UIViewBase.cs | 13 ------------- .../Assets/Scripts/GameTools/UI/UIViewExport.cs | 13 +++++++++++++ 5 files changed, 15 insertions(+), 32 deletions(-) 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; + } }