UI系统优化
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae50b43961101f54f9b0c8c42f833c52
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -40,8 +40,8 @@ namespace BaseGames.Editor.Dialogue
|
||||
if (string.IsNullOrEmpty(resolved))
|
||||
{
|
||||
EditorGUILayout.HelpBox(
|
||||
$"nameKey「{npc.nameKey}」在本地化表「{npc.localizationTable}」中未找到对应文本(或 LocalizationManager 未初始化)。\n" +
|
||||
"请检查本地化表中是否存在此 Key。",
|
||||
$"nameKey「{npc.nameKey}」在本地化表「{npc.localizationTable}」中未找到对应文本。\n" +
|
||||
"请检查本地化 JSON 文件中是否存在此 Key。",
|
||||
MessageType.Warning);
|
||||
}
|
||||
else
|
||||
@@ -51,10 +51,15 @@ namespace BaseGames.Editor.Dialogue
|
||||
s_previewStyle);
|
||||
}
|
||||
|
||||
// ── 跳转到本地化文件 ────────────────────────────────────────────
|
||||
// ── 操作按钮行 ─────────────────────────────────────────────────
|
||||
EditorGUILayout.Space(4);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GUILayout.Button("刷新预览", GUILayout.Width(80)))
|
||||
{
|
||||
BaseGames.Localization.LocalizationManager.ClearEditorPreviewCache();
|
||||
Repaint();
|
||||
}
|
||||
if (GUILayout.Button($"跳转到本地化文件({npc.localizationTable} 表)", GUILayout.Width(220)))
|
||||
{
|
||||
PingLocalizationFile(npc.localizationTable);
|
||||
@@ -63,21 +68,13 @@ namespace BaseGames.Editor.Dialogue
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试通过 LocalizationManager(若已加载)解析 nameKey;
|
||||
/// 如未初始化或找不到 Key,返回 null。
|
||||
/// 编辑器预览:直接从 Resources 读取本地化文本,无需运行时服务实例。
|
||||
/// 找不到时返回 null(让上层显示 warning 而非 key 本身)。
|
||||
/// </summary>
|
||||
private static string TryResolveNameKey(string key, string table = "UI")
|
||||
private static string TryResolveNameKey(string key, string table = BaseGames.Localization.LocalizationTable.UI)
|
||||
{
|
||||
try
|
||||
{
|
||||
// LocalizationManager.Get 在编辑器下可能返回空字符串(未初始化),视为未找到
|
||||
var resolved = BaseGames.Localization.LocalizationManager.Get(key, table);
|
||||
return string.IsNullOrEmpty(resolved) ? null : resolved;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// GetEditorPreview 直接读 JSON,编辑器下不依赖 ServiceLocator 实例
|
||||
return BaseGames.Localization.LocalizationManager.GetEditorPreview(key, table);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
11
Assets/_Game/Scripts/Editor/Dialogue/NpcSOEditor.cs.meta
Normal file
11
Assets/_Game/Scripts/Editor/Dialogue/NpcSOEditor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c09dcd9907ab854da42443d37ff52f9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user