fix: 梦境对话跳Warning

This commit is contained in:
2026-07-19 19:05:06 +08:00
parent 05fe1ebb60
commit c3da27d07c
+15 -10
View File
@@ -33,22 +33,27 @@ namespace AibisDream
// 先中断结束事件
_autoHideToken?.Cancel();
_autoHideToken = null;
OnTextShowed = null;
// 注册事件
// 先激活并清空文本,再订阅 onTextShowed。
// box 从 HideDialog 恢复时会触发 Typewriter OnEnable → StartShowingText → 同步 onTextShowed
// 若此时尚未注册回调,或旧文本已全可见,会在 TextStart 之前把 token 推进到 AdvanceDelay。
if (box != null && !box.activeSelf)
box.SetActive(true);
content.StopShowingText();
content.TextAnimator.SetText(string.Empty);
var lineText = GetOneLineText(syncToken.lineInfo);
HandleLayout(lineText);
// 注册事件(UI 就绪后再挂回调)
OnTextShowed += syncToken.TextShown;
syncToken.SkipTextAnima += () => content.SkipTypewriter();
syncToken.OnAdvance += AfterAdvance;
// TMP ClearMesh 依赖 canvasRendererbox 未激活时 SetText 会 NRE
if (box != null && !box.activeSelf)
box.SetActive(true);
// 播放文字
content.TextAnimator.SetText(string.Empty);
var lineText = GetOneLineText(syncToken.lineInfo);
HandleLayout(lineText);
content.ShowText(lineText);
syncToken.TextStart();
content.ShowText(lineText);
}
private string GetOneLineText(LineInfo lineInfo)