diff --git a/Assets/Scripts/UI/DialogUI/OnelineBox.cs b/Assets/Scripts/UI/DialogUI/OnelineBox.cs index deb3d9d14..8e2ca88cf 100644 --- a/Assets/Scripts/UI/DialogUI/OnelineBox.cs +++ b/Assets/Scripts/UI/DialogUI/OnelineBox.cs @@ -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 依赖 canvasRenderer;box 未激活时 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)