This commit is contained in:
SoulliesOfficial
2026-07-24 03:43:11 -04:00
parent 48e7364981
commit fe00ecfcc7
90 changed files with 9610 additions and 461 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Ichni.Diagnostics;
using Ichni.Menu.UI;
using TMPro;
using UnityEngine;
@@ -421,12 +422,38 @@ namespace Ichni.Story.UI
}
}
private void OnSelectedLocaleChanged(Locale _)
private async void OnSelectedLocaleChanged(Locale newLocale)
{
BuildHangTracer.Log("TIMELINE_EVENT", $"[OnSelectedLocaleChanged] 收到语言切换通知: newLocale={(newLocale != null ? newLocale.Identifier.Code : "null")}_markers.Count={_markers.Count}");
foreach (RuntimeMarker marker in _markers)
{
marker.view.SetLabel(GetLocalizedLabel(marker.definition.labelKey));
if (string.IsNullOrEmpty(marker.definition.labelKey)) continue;
try
{
BuildHangTracer.Log("TIMELINE_EVENT", $"[OnSelectedLocaleChanged] 开始异步获取 Key '{marker.definition.labelKey}' 的本地化文本...");
var handle = LocalizationSettings.StringDatabase.GetLocalizedStringAsync(localizationTable, marker.definition.labelKey);
while (!handle.IsDone)
{
await System.Threading.Tasks.Task.Yield();
}
BuildHangTracer.Log("TIMELINE_EVENT", $"[OnSelectedLocaleChanged] 获取 Key '{marker.definition.labelKey}' 完成Result='{handle.Result}'");
// 异步等待结束后,防范对象在此期间被销毁
if (marker.view != null)
{
marker.view.SetLabel(string.IsNullOrEmpty(handle.Result) ? marker.definition.labelKey : handle.Result);
}
}
catch (System.Exception exception)
{
BuildHangTracer.Log("TIMELINE_EVENT", $"[OnSelectedLocaleChanged] 异常: {exception.Message}");
Debug.LogWarning($"[StoryTimeline] 无法本地化 Label Key '{marker.definition.labelKey}'。{exception.Message}");
if (marker.view != null) marker.view.SetLabel(marker.definition.labelKey);
}
}
BuildHangTracer.Log("TIMELINE_EVENT", "[OnSelectedLocaleChanged] 全部 Marker 更新完成。");
}
/// <summary>