UI系统优化

This commit is contained in:
2026-05-25 11:54:37 +08:00
parent c7057db27d
commit 3c812cfb41
130 changed files with 4738 additions and 477 deletions

View File

@@ -4,6 +4,7 @@ using UnityEngine;
using TMPro;
using BaseGames.Core;
using BaseGames.Core.Events;
using BaseGames.Localization;
namespace BaseGames.World.Map
{
@@ -90,7 +91,8 @@ namespace BaseGames.World.Map
{
if (_regionNames != null)
foreach (var e in _regionNames)
if (e.RegionId == regionId) return e.DisplayName;
if (e.RegionId == regionId)
return e.GetDisplayName();
return regionId;
}
}
@@ -98,7 +100,26 @@ namespace BaseGames.World.Map
[Serializable]
public struct RegionNameEntry
{
[Tooltip("场景/区域 ID与 EVT_RegionChanged 事件传递的字符串匹配。")]
public string RegionId;
[Tooltip("本地化 Key如 REGION_CITY_NAME。设置后运行时通过 LocalizationManager 自动解析。")]
public string LocKey;
[Tooltip("直接显示名LocKey 为空时使用)。建议优先配置 LocKey仅在开发或单语言项目中直接善用。")]
public string DisplayName;
/// <summary>返回最终显示名:优先读 LocKey其次 DisplayName最后回退到 RegionId。</summary>
public string GetDisplayName()
{
if (!string.IsNullOrEmpty(LocKey))
{
string localized = LocalizationManager.Get(LocKey, LocalizationTable.UI);
// LocalizationManager 在未找到 Key 时返回 Key 本身,判断是否是真正翻译结果
if (!string.IsNullOrEmpty(localized) && localized != LocKey)
return localized;
}
return !string.IsNullOrEmpty(DisplayName) ? DisplayName : RegionId;
}
}
}