diff --git a/Editor/UIExtension/Text/UXTextMeshProEditor.cs b/Editor/UIExtension/Text/UXTextMeshProEditor.cs index 1e39395..93fef60 100644 --- a/Editor/UIExtension/Text/UXTextMeshProEditor.cs +++ b/Editor/UIExtension/Text/UXTextMeshProEditor.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using AlicizaX.Localization.Editor; using AlicizaX.Localization.Runtime; using UnityEditor; +using UnityEditor.UIElements; using UnityEngine; namespace UnityEngine.UI @@ -12,14 +13,12 @@ namespace UnityEngine.UI { private SerializedProperty text; private SerializedProperty localizationID; - private List _entries; protected override void OnEnable() { text = serializedObject.FindProperty("m_text"); localizationID = serializedObject.FindProperty("m_localizationID"); base.OnEnable(); - _entries = LocalizationMasterConfig.GetAllEntries(); } public override void OnInspectorGUI() @@ -28,56 +27,24 @@ namespace UnityEngine.UI bool isPlay = Application.isPlaying; - // 准备Key列表 - string[] keys = new string[_entries.Count]; - for (int i = 0; i < _entries.Count; i++) - { - keys[i] = _entries[i].ID; - } - // Key选择逻辑 - EditorGUI.BeginDisabledGroup(isPlay); - { - int currentIndex = -1; - for (int i = 0; i < keys.Length; i++) - { - if (localizationID.stringValue == keys[i]) - { - currentIndex = i; - break; - } - } + EditorGUILayout.PropertyField(localizationID); - // 显示警告如果Key不存在 - if (currentIndex == -1 && !string.IsNullOrEmpty(localizationID.stringValue)) - { - EditorGUILayout.HelpBox("当前Key在配置文件中不存在", MessageType.Warning); - } - - // 绘制Key下拉菜单 - int newIndex = EditorGUILayout.Popup("本地化Key", currentIndex, keys); - if (newIndex != currentIndex && newIndex >= 0) - { - localizationID.stringValue = keys[newIndex]; - text.stringValue = _entries[newIndex].ChineseSimplified; - } - } - EditorGUI.EndDisabledGroup(); - - // 显示预览信息 - EditorGUI.BeginDisabledGroup(true); - { - EditorGUILayout.PropertyField(localizationID); - if (!string.IsNullOrEmpty(localizationID.stringValue)) - { - var entry = _entries.Find(e => e.ID == localizationID.stringValue); - if (entry != null) - { - EditorGUILayout.TextField("当前文本预览", entry.ChineseSimplified); - } - } - } - EditorGUI.EndDisabledGroup(); + // + // // 显示预览信息 + // EditorGUI.BeginDisabledGroup(true); + // { + // EditorGUILayout.PropertyField(localizationID); + // if (!string.IsNullOrEmpty(localizationID.stringValue)) + // { + // var entry = _entries.Find(e => e.ID == localizationID.stringValue); + // if (entry != null) + // { + // EditorGUILayout.TextField("当前文本预览", entry.ChineseSimplified); + // } + // } + // } + // EditorGUI.EndDisabledGroup(); serializedObject.ApplyModifiedProperties(); base.OnInspectorGUI();