From e90da7bab7726c073a1e1565d30c1531f0ed985e Mon Sep 17 00:00:00 2001
From: Ding Yuntian <1491671119@qq.com>
Date: Wed, 24 Jun 2026 22:44:43 +0800
Subject: [PATCH] =?UTF-8?q?fix(save-system):=20=E4=BF=AE=E5=A4=8D=E8=AF=BB?=
=?UTF-8?q?=E6=A1=A3=E6=97=B6=20UI=20=E4=B8=8E=E6=B8=B8=E6=88=8F=E7=8A=B6?=
=?UTF-8?q?=E6=80=81=E6=9C=AA=E5=AF=B9=E9=BD=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../SaveSystem/SaveRestoreOrchestrator.cs | 64 ++++++++++++++++++-
Assets/Scripts/SaveSystem/SnapshotRestore.cs | 3 +
2 files changed, 64 insertions(+), 3 deletions(-)
diff --git a/Assets/Scripts/SaveSystem/SaveRestoreOrchestrator.cs b/Assets/Scripts/SaveSystem/SaveRestoreOrchestrator.cs
index 8fc5ceb94..71350cd9b 100644
--- a/Assets/Scripts/SaveSystem/SaveRestoreOrchestrator.cs
+++ b/Assets/Scripts/SaveSystem/SaveRestoreOrchestrator.cs
@@ -152,7 +152,7 @@ namespace AibisDream.SaveSystem
return new AutoSaveSuppressScope(reason);
}
- /// 旧档:Yarn 变量 + DeepRepairDataRegistry systemData。
+ /// 旧档:仅恢复 Yarn 变量,再 Capture 写入 slot_0 完成格式迁移。
private static IEnumerator RestoreLegacy(string savePath)
{
var saveData = SnapshotPersistence.ReadLegacySaveRoot(savePath);
@@ -161,13 +161,16 @@ namespace AibisDream.SaveSystem
var boolDict = saveData["boolDict"]?.ToObject>();
YarnVariableStorage.Instance.SetAllVariables(floatDict, stringDict, boolDict);
- if (saveData["systemData"] is JObject systemDataJson)
+ if (saveData["systemData"] != null)
{
- yield return DeepRepairDataRegistry.LoadByJson(systemDataJson);
+ Debug.LogWarning(
+ "[SaveRestoreOrchestrator] 旧档 systemData 段已无法还原(IData 已移除);" +
+ "仅恢复 Yarn 变量并迁移为新快照格式。");
}
var snapshot = SnapshotService.Capture();
SlotManager.SaveToAutoSlot(snapshot, null);
+ yield break;
}
private static IEnumerator RestoreLegacyWithFlow(string savePath)
@@ -180,8 +183,10 @@ namespace AibisDream.SaveSystem
try
{
yield return FadeInForRestore();
+ PrepareGameSessionForRestore();
yield return RestoreLegacy(savePath);
yield return null;
+ FinalizeGameSessionAfterRestore();
yield return FadeOutForRestore();
}
finally
@@ -210,6 +215,8 @@ namespace AibisDream.SaveSystem
{
yield return FadeInForRestore();
+ PrepareGameSessionForRestore();
+
SnapshotRegistry.EnsureInitialized();
yield return SnapshotRestore.RestoreState(YarnVariableStorage.Instance, snapshot, context);
yield return SnapshotRestore.RestoreAnchor(snapshot, context);
@@ -217,6 +224,8 @@ namespace AibisDream.SaveSystem
AddRestoreLog("Phase 3.5: settle one frame");
yield return null;
+ FinalizeGameSessionAfterRestore();
+
yield return FadeOutForRestore();
}
finally
@@ -227,6 +236,55 @@ namespace AibisDream.SaveSystem
}
}
+ ///
+ /// 读档前对齐「已进入游戏」的 UI 与输入状态。
+ /// 编辑器测试工具等路径可能跳过 ,导致 StartPanel 未关闭、
+ /// 为 false,从而无法推进对话。
+ ///
+ private static void PrepareGameSessionForRestore()
+ {
+ AddRestoreLog("Prepare game session for restore");
+
+ var gameManager = GameManager.Instance;
+ if (gameManager != null && !gameManager.state.isInGame)
+ {
+ EnumEventSystem.Global.Send(GameLoopEnum.GameStart);
+ }
+
+ var ui = UIManager.Instance;
+ if (ui != null)
+ {
+ ui.HidePanel();
+ ui.ShowPanel();
+ ui.HidePanel();
+ ui.HidePanel();
+ ui.HidePanel();
+ }
+
+ if (gameManager != null && gameManager.state.isInPause)
+ {
+ gameManager.ContinueGame();
+ }
+ else
+ {
+ DialogUIManager.Instance?.OpenCanvas();
+ }
+ }
+
+ /// 读档完成后确保对话 Canvas 可用、退出暂停态。
+ private static void FinalizeGameSessionAfterRestore()
+ {
+ AddRestoreLog("Finalize game session after restore");
+
+ DialogUIManager.Instance?.OpenCanvas();
+
+ var gameManager = GameManager.Instance;
+ if (gameManager != null && gameManager.state.isInPause)
+ {
+ gameManager.ContinueGame();
+ }
+ }
+
private static IEnumerator FadeInForRestore()
{
AddRestoreLog("Begin restore fade in");
diff --git a/Assets/Scripts/SaveSystem/SnapshotRestore.cs b/Assets/Scripts/SaveSystem/SnapshotRestore.cs
index 91902f622..79ddebd02 100644
--- a/Assets/Scripts/SaveSystem/SnapshotRestore.cs
+++ b/Assets/Scripts/SaveSystem/SnapshotRestore.cs
@@ -115,6 +115,9 @@ namespace AibisDream.SaveSystem
}
yield return sceneLoader.LoadSceneAsync(snapshot.scene.sceneName);
+
+ // 再等一帧,等Awake执行完
+ yield return null;
}
private static void RestoreSceneSo(SaveSnapshot snapshot, SnapshotRestoreContext context)