SaveLoad using managed lifecycle

This commit is contained in:
Michal Pikulski
2025-11-04 20:01:27 +01:00
parent 379a033d6b
commit bb68d1fd31
23 changed files with 1083 additions and 648 deletions

View File

@@ -41,7 +41,7 @@ namespace Levels
/// </summary>
protected override void Awake()
{
base.Awake(); // Register with save system
base.Awake();
switchActive = true;
if (iconRenderer == null)
@@ -51,12 +51,12 @@ namespace Levels
interactionSettings = GameManager.GetSettingsObject<IInteractionSettings>();
ApplySwitchData();
}
protected override void Start()
protected override void OnManagedAwake()
{
base.Start(); // Register with save system
base.OnManagedAwake();
// Direct subscription - PuzzleManager available by this point
// Subscribe to PuzzleManager - safe to access .Instance here
if (PuzzleManager.Instance != null)
{
PuzzleManager.Instance.OnAllPuzzlesComplete += HandleAllPuzzlesComplete;
@@ -69,8 +69,10 @@ namespace Levels
}
}
private void OnDestroy()
protected override void OnDestroy()
{
base.OnDestroy();
if (PuzzleManager.Instance != null)
{
PuzzleManager.Instance.OnAllPuzzlesComplete -= HandleAllPuzzlesComplete;