From 80d32a73d8fa5dc90fe4873e427ec3bb51b1888c Mon Sep 17 00:00:00 2001 From: bottlefish <781230111@qq.com> Date: Thu, 2 Jul 2026 16:38:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(ui):=20=E4=B8=BB=E7=95=8C=E9=9D=A2=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E5=89=8D=E9=BB=91=E5=B1=8F=E9=81=AE=E7=BD=A9=EF=BC=8C?= =?UTF-8?q?=E5=B0=B1=E7=BB=AA=E5=90=8E=E5=86=8D=E6=B7=A1=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- .../Framework/OtherKit/LocalizationKit.cs | 21 ++++++++- Assets/Scripts/Game Loop/GameManager.cs | 46 +++++++++++++++++-- Assets/Scripts/UI/Panel/PlayToolPanel.cs | 10 ++-- 3 files changed, 65 insertions(+), 12 deletions(-) diff --git a/Assets/Scripts/Framework/OtherKit/LocalizationKit.cs b/Assets/Scripts/Framework/OtherKit/LocalizationKit.cs index 0de3f1307..36e18ec70 100644 --- a/Assets/Scripts/Framework/OtherKit/LocalizationKit.cs +++ b/Assets/Scripts/Framework/OtherKit/LocalizationKit.cs @@ -1,4 +1,5 @@ -using AibisDream.Kit; +using System.Collections; +using AibisDream.Kit; using UnityEngine; using UnityEngine.Localization; using UnityEngine.Localization.Settings; @@ -137,5 +138,23 @@ namespace AibisDream.Framework { await LocalizationSettings.InitializationOperation.Task; } + + /// + /// 等待本地化系统初始化完成(含 SettingLoader 触发的语言切换)。 + /// + public static IEnumerator WaitUntilReady() + { + yield return LocalizationSettings.InitializationOperation; + yield return null; + } + + /// + /// 等待 LocalizeStringEvent 等 UI 组件刷新文案。 + /// + public static IEnumerator WaitForUIRefresh() + { + yield return null; + Canvas.ForceUpdateCanvases(); + } } } \ No newline at end of file diff --git a/Assets/Scripts/Game Loop/GameManager.cs b/Assets/Scripts/Game Loop/GameManager.cs index 951947f3b..12e898e30 100644 --- a/Assets/Scripts/Game Loop/GameManager.cs +++ b/Assets/Scripts/Game Loop/GameManager.cs @@ -22,6 +22,8 @@ namespace AibisDream #endregion + private const float MainMenuFadeDuration = 0.5f; + private BindProperty _currentTalkSceneSo; public override void OnSingletonInit() { @@ -36,9 +38,28 @@ namespace AibisDream // 场景So事件注册 _currentTalkSceneSo = new BindProperty(); - ActionKit.Sequence() - .Callback(() => EnumEventSystem.Global.Send(GameLoopEnum.AppStart)) - .Start(this); + StartCoroutine(AppBootstrapCoroutine()); + } + + /// + /// 启动主界面:先黑屏,待本地化与 UI 就绪后再淡出,避免玩家看到初始化过程。 + /// + private IEnumerator AppBootstrapCoroutine() + { + var playTool = UIManager.Instance.GetPanel(); + UIManager.Instance.ShowPanel(); + playTool?.ApplyFadeScreenCovered(true); + + yield return LocalizationKit.WaitUntilReady(); + + EnumEventSystem.Global.Send(GameLoopEnum.AppStart); + + yield return LocalizationKit.WaitForUIRefresh(); + + if (playTool != null) + { + yield return playTool.FadeOutAsync(MainMenuFadeDuration); + } } private void LoadAllSceneSos() @@ -202,7 +223,12 @@ namespace AibisDream private IEnumerator RestartCoroutine() { - UIManager.Instance.GetPanel().FadeInSync(0.1f); + var playTool = UIManager.Instance.GetPanel(); + UIManager.Instance.ShowPanel(); + if (playTool != null) + { + yield return playTool.FadeInAsync(MainMenuFadeDuration); + } // 清理所有系统注册 if (FixSystemCenter.SystemDic != null) @@ -210,10 +236,15 @@ namespace AibisDream FixSystemCenter.SystemDic.Clear(); } + playTool?.ClearPresentationEffects(); + // 执行场景卸载等功能 CameraKit.Instance.ResetCamera(); yield return SceneLoader.Instance.UnloadSceneAsync(); DialogController.Instance.StopDialog(); + + yield return LocalizationKit.WaitUntilReady(); + EnumEventSystem.Global.Send(GameLoopEnum.GameQuit); // 音频继续 AudioManager.Instance.UnPauseAll(); @@ -222,7 +253,12 @@ namespace AibisDream // 关闭结束面板 UIManager.Instance.HidePanel(); - yield return UIManager.Instance.GetPanel().FadeOutAsync(); + yield return LocalizationKit.WaitForUIRefresh(); + + if (playTool != null) + { + yield return playTool.FadeOutAsync(MainMenuFadeDuration); + } } #endregion diff --git a/Assets/Scripts/UI/Panel/PlayToolPanel.cs b/Assets/Scripts/UI/Panel/PlayToolPanel.cs index da7a216bf..a7a867873 100644 --- a/Assets/Scripts/UI/Panel/PlayToolPanel.cs +++ b/Assets/Scripts/UI/Panel/PlayToolPanel.cs @@ -42,7 +42,6 @@ namespace AibisDream.UI private void Awake() { InitRefs(); - EnumEventSystem.Global.Register(GameLoopEnum.GameQuit, HideAll); } private void InitRefs() @@ -240,14 +239,13 @@ namespace AibisDream.UI _signBoard.CloseSignBoard(); } - private void HideAll() + /// + /// 清理演出层内容,但不影响黑屏遮罩(用于返回主界面时在遮罩下重置状态)。 + /// + public void ClearPresentationEffects() { _timeFlowsVersion++; - _fadeImage.DOKill(); - _fadeImage.color = Color.clear; - _fadeImage.gameObject.SetActive(false); - _fullScreenImage.FadeOut(0.1f); _showObjImage.FadeOut(0.1f); _showObjPanel.SetActive(false);