From f6715dbfaedecb2bd139b7f3b9872a281697a955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=80=9D=E6=B5=B7?= <1464576565@qq.com> Date: Tue, 16 Dec 2025 17:08:10 +0800 Subject: [PATCH] fix --- Editor/UX/UXTextMeshPro/UXTextMeshProEditor.cs | 1 + Runtime/UXComponent/Text/UXTextMeshPro.cs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Editor/UX/UXTextMeshPro/UXTextMeshProEditor.cs b/Editor/UX/UXTextMeshPro/UXTextMeshProEditor.cs index c28028c..b86cbf5 100644 --- a/Editor/UX/UXTextMeshPro/UXTextMeshProEditor.cs +++ b/Editor/UX/UXTextMeshPro/UXTextMeshProEditor.cs @@ -147,6 +147,7 @@ namespace UnityEngine.UI // 检查是否找不到对应 ID 的 key if (localizationID.intValue > 0 && !allTableNames.ContainsKey(localizationID.intValue)) { + m_localizationKey.stringValue = string.Empty; EditorGUILayout.HelpBox($"已选择的多语言 Key (ID={localizationID.intValue}) 已被删除,但仍然保留该 ID。", MessageType.Warning); } diff --git a/Runtime/UXComponent/Text/UXTextMeshPro.cs b/Runtime/UXComponent/Text/UXTextMeshPro.cs index 188c5f9..1403108 100644 --- a/Runtime/UXComponent/Text/UXTextMeshPro.cs +++ b/Runtime/UXComponent/Text/UXTextMeshPro.cs @@ -12,7 +12,10 @@ namespace UnityEngine.UI protected override void OnValidate() { base.OnValidate(); - if (!Application.isPlaying) text = LocalizationRefreshHelper.GetPreviewLabel(m_localizationKey); + if (!Application.isPlaying && !string.IsNullOrEmpty(m_localizationKey)) + { + text = LocalizationRefreshHelper.GetPreviewLabel(m_localizationKey); + } } #endif protected override void Start()