SaveLoad using managed lifecycle

This commit is contained in:
Michal Pikulski
2025-11-04 20:01:27 +01:00
committed by Michal Pikulski
parent 3e835ed3b8
commit b932be2232
19 changed files with 1042 additions and 627 deletions

View File

@@ -47,7 +47,7 @@ namespace Levels
/// </summary>
protected override void Awake()
{
base.Awake(); // Register with save system
base.Awake();
switchActive = true;
if (iconRenderer == null)
@@ -63,10 +63,10 @@ namespace Levels
interactionSettings = GameManager.GetSettingsObject<IInteractionSettings>();
ApplySwitchData();
}
protected override void Start()
protected override void OnManagedAwake()
{
base.Start(); // Register with save system
base.OnManagedAwake();
// If startUnlocked is true, always start active
if (startUnlocked)
@@ -74,8 +74,7 @@ namespace Levels
gameObject.SetActive(true);
return;
}
// Direct subscription - PuzzleManager available by this point
if (PuzzleManager.Instance != null)
{
PuzzleManager.Instance.OnAllPuzzlesComplete += HandleAllPuzzlesComplete;
@@ -87,8 +86,10 @@ namespace Levels
}
}
private void OnDestroy()
protected override void OnDestroy()
{
base.OnDestroy();
if (PuzzleManager.Instance != null)
{
PuzzleManager.Instance.OnAllPuzzlesComplete -= HandleAllPuzzlesComplete;