Fix issues with puzzle loading order and add saving state when using Menu
This commit is contained in:
committed by
Michal Pikulski
parent
c527ba334d
commit
717deee0cd
@@ -50,7 +50,24 @@ namespace PuzzleS
|
||||
|
||||
// Save system configuration
|
||||
public override bool AutoRegisterForSave => true;
|
||||
public override string SaveId => $"{SceneManager.GetActiveScene().name}/PuzzleManager";
|
||||
|
||||
/// <summary>
|
||||
/// SaveId uses CurrentGameplayScene instead of GetActiveScene() because PuzzleManager
|
||||
/// lives in DontDestroyOnLoad and needs to save/load data per-scene.
|
||||
/// </summary>
|
||||
public override string SaveId
|
||||
{
|
||||
get
|
||||
{
|
||||
string sceneName = SceneManagerService.Instance?.CurrentGameplayScene;
|
||||
if (string.IsNullOrEmpty(sceneName))
|
||||
{
|
||||
// Fallback during early initialization
|
||||
sceneName = SceneManager.GetActiveScene().name;
|
||||
}
|
||||
return $"{sceneName}/PuzzleManager";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Singleton instance of the PuzzleManager.
|
||||
@@ -602,7 +619,8 @@ namespace PuzzleS
|
||||
// Update any behaviors that registered before RestoreState was called
|
||||
foreach (var behaviour in _pendingRegistrations)
|
||||
{
|
||||
UpdateStepState(behaviour);
|
||||
if(behaviour != null)
|
||||
UpdateStepState(behaviour);
|
||||
}
|
||||
_pendingRegistrations.Clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user