From 0a1adf155880c06661ee5893786d6d538fc7b55e Mon Sep 17 00:00:00 2001 From: Ding Yuntian <1491671119@qq.com> Date: Sun, 26 Jul 2026 16:36:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=83=A8=E5=88=86QA=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 返回主菜单闪烁 2. 对话隐藏 3. 历史记录宽度调整 --- .../Prefabs/Common/TerminalRecordItem.prefab | 8 ++-- .../Scripts/Dialog System/DialogController.cs | 5 +++ Assets/Scripts/Game Loop/GameManager.cs | 8 +++- Assets/Scripts/UI/DialogUI/DialogUIManager.cs | 26 ++++++++---- .../UI/Terminal/InGameTerminalPanel.cs | 42 ++++++++++++++++++- .../UI/Terminal/TerminalRecordItemView.cs | 2 - 6 files changed, 74 insertions(+), 17 deletions(-) diff --git a/Assets/GameContent/Feature_MainUI/Prefabs/Common/TerminalRecordItem.prefab b/Assets/GameContent/Feature_MainUI/Prefabs/Common/TerminalRecordItem.prefab index afda87934..e282fb2a5 100644 --- a/Assets/GameContent/Feature_MainUI/Prefabs/Common/TerminalRecordItem.prefab +++ b/Assets/GameContent/Feature_MainUI/Prefabs/Common/TerminalRecordItem.prefab @@ -242,11 +242,11 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_IgnoreLayout: 0 - m_MinWidth: -1 + m_MinWidth: 137.5 m_MinHeight: -1 m_PreferredWidth: 137.5 m_PreferredHeight: -1 - m_FlexibleWidth: -1 + m_FlexibleWidth: 0 m_FlexibleHeight: -1 m_LayoutPriority: 1 --- !u!1 &9149096767179396398 @@ -398,9 +398,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_IgnoreLayout: 0 - m_MinWidth: -1 + m_MinWidth: 0 m_MinHeight: -1 - m_PreferredWidth: -1 + m_PreferredWidth: 0 m_PreferredHeight: -1 m_FlexibleWidth: 1 m_FlexibleHeight: -1 diff --git a/Assets/Scripts/Dialog System/DialogController.cs b/Assets/Scripts/Dialog System/DialogController.cs index 827ce4e14..71ce27eb0 100644 --- a/Assets/Scripts/Dialog System/DialogController.cs +++ b/Assets/Scripts/Dialog System/DialogController.cs @@ -109,6 +109,11 @@ namespace AibisDream yield return _dialogueRunner.Stop(); } + // Yarn Spinner runs IEnumerator commands as coroutines on the + // DialogueRunner. Stopping the dialogue does not stop those detached + // coroutines, so cancel them explicitly before a scene/session teardown. + _dialogueRunner?.StopAllCoroutines(); + SavePointEvaluator.ResetForProject(null); YarnVariableStorage.Instance.Clear(); DialogUIManager.Instance.HideDialog(); diff --git a/Assets/Scripts/Game Loop/GameManager.cs b/Assets/Scripts/Game Loop/GameManager.cs index 356a595f4..97ad96361 100644 --- a/Assets/Scripts/Game Loop/GameManager.cs +++ b/Assets/Scripts/Game Loop/GameManager.cs @@ -539,14 +539,17 @@ namespace AibisDream } EnumEventSystem.Global.Send(GameLifecycleEvent.SessionEnding); - ResumeSessionInternal(sendEvent: _session.IsPaused); - yield return FadeIn(); if (DialogController.Instance != null) { yield return DialogController.Instance.StopDialogRoutine(); } + // The in-game terminal remains visible while this transition + // covers the gameplay behind it. + yield return FadeIn(); + UIManager.Instance.GetPanel()?.CloseForSessionEnd(); + // The showcase belongs to the loaded gameplay scene, so clear it // while that scene is still alive and hidden behind the fade. ResetPresentationEffects(); @@ -579,6 +582,7 @@ namespace AibisDream UIManager.Instance.HidePanel(); yield return LocalizationKit.WaitUntilReady(); + ResumeSessionInternal(sendEvent: _session.IsPaused); _session.ResetRuntimeState(); TrySetPhase(GameSessionPhase.MainMenu); EnumEventSystem.Global.Send(GameLifecycleEvent.SessionEnded); diff --git a/Assets/Scripts/UI/DialogUI/DialogUIManager.cs b/Assets/Scripts/UI/DialogUI/DialogUIManager.cs index 9c8020846..8a9372194 100644 --- a/Assets/Scripts/UI/DialogUI/DialogUIManager.cs +++ b/Assets/Scripts/UI/DialogUI/DialogUIManager.cs @@ -14,6 +14,8 @@ namespace AibisDream private CanvasGroup _canvasGroup; private BubbleSlotGroupData? _pendingBubbleData; + private bool _isCanvasOpen = true; + private bool _isDialogVisualVisible = true; public override void OnSingletonInit() { @@ -23,6 +25,8 @@ namespace AibisDream _canvasGroup = gameObject.AddComponent(); } + ApplyCanvasGroupState(); + EnumEventSystem.Global.Register(DialogEventEnum.LineStart, AddDialogueLine); EnumEventSystem.Global.Register(DialogEventEnum.LineHistoryAppend, AddDialogueLine); EnumEventSystem.Global.Register(DialogEventEnum.OptionSelected, AddDialogueLine); @@ -67,12 +71,14 @@ namespace AibisDream public void CloseCanvas() { - gameObject.SetActive(false); + _isCanvasOpen = false; + ApplyCanvasGroupState(); } public void OpenCanvas() { - gameObject.SetActive(true); + _isCanvasOpen = true; + ApplyCanvasGroupState(); } /// @@ -80,12 +86,18 @@ namespace AibisDream /// public void SetDialogVisualVisible(bool visible) { - if (_canvasGroup == null) - { - _canvasGroup = GetComponent(); - } + _isDialogVisualVisible = visible; + ApplyCanvasGroupState(); + } - _canvasGroup.alpha = visible ? 1f : 0f; + private void ApplyCanvasGroupState() + { + _canvasGroup.alpha = _isCanvasOpen && _isDialogVisualVisible ? 1f : 0f; + + // SetDialogVisualVisible remains visual-only. Pause-driven canvas state + // exclusively controls whether dialogue UI can interact or block raycasts. + _canvasGroup.interactable = _isCanvasOpen; + _canvasGroup.blocksRaycasts = _isCanvasOpen; } public void HideDialog() diff --git a/Assets/Scripts/UI/Terminal/InGameTerminalPanel.cs b/Assets/Scripts/UI/Terminal/InGameTerminalPanel.cs index 2ff2c3bfb..0ed128754 100644 --- a/Assets/Scripts/UI/Terminal/InGameTerminalPanel.cs +++ b/Assets/Scripts/UI/Terminal/InGameTerminalPanel.cs @@ -24,6 +24,7 @@ namespace AibisDream.UI private readonly Stack _backStack = new(); private InGameTerminalPage _currentPage = InGameTerminalPage.None; private bool _pausedByPanel; + private bool _isReturningToMainMenu; public bool IsOpen => gameObject.activeSelf && _currentPage != InGameTerminalPage.None; public bool IsCloseable => false; @@ -69,6 +70,7 @@ namespace AibisDream.UI return; } + _isReturningToMainMenu = false; if (!IsOpen) { _backStack.Clear(); @@ -124,12 +126,22 @@ namespace AibisDream.UI return false; } + if (_isReturningToMainMenu) + { + return true; + } + Back(); return true; } public void Close() { + if (_isReturningToMainMenu) + { + return; + } + Close(restoreAmb: true); } @@ -144,8 +156,34 @@ namespace AibisDream.UI public void CloseToMainMenu() { - Close(restoreAmb: false); - GameManager.Instance.TryReturnToMainMenu(); + if (_isReturningToMainMenu || GameManager.Instance == null) + { + return; + } + + if (GameManager.Instance.TryReturnToMainMenu()) + { + // Keep this full-screen panel visible while the global transition + // covers the gameplay behind it. GameManager closes it only after + // the screen is fully covered. + _isReturningToMainMenu = true; + } + } + + public void CloseForSessionEnd() + { + HideAllPages(); + _backStack.Clear(); + _currentPage = InGameTerminalPage.None; + + if (_pausedByPanel) + { + TerminalUIAudio.NotifyPauseMenuAmbExit(restorePrevious: false); + _pausedByPanel = false; + } + + _isReturningToMainMenu = false; + gameObject.SetActive(false); } public void SetHeader(string title, string status = "") diff --git a/Assets/Scripts/UI/Terminal/TerminalRecordItemView.cs b/Assets/Scripts/UI/Terminal/TerminalRecordItemView.cs index 11f77ca86..fd8cc3efa 100644 --- a/Assets/Scripts/UI/Terminal/TerminalRecordItemView.cs +++ b/Assets/Scripts/UI/Terminal/TerminalRecordItemView.cs @@ -13,13 +13,11 @@ namespace AibisDream.UI if (actorNameText != null) { actorNameText.text = lineInfo.character.GetActorName(); - actorNameText.ForceMeshUpdate(); } if (lineText != null) { lineText.text = lineInfo.GetRecordLine(); - lineText.ForceMeshUpdate(); } gameObject.SetActive(true);