From c3da27d07cf614642b795771c45174cc53f440b4 Mon Sep 17 00:00:00 2001 From: Ding Yuntian <1491671119@qq.com> Date: Sun, 19 Jul 2026 19:05:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=A2=A6=E5=A2=83=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E8=B7=B3Warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/UI/DialogUI/OnelineBox.cs | 25 ++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) 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)