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()