Fix pausing etc. issues in the minigame

This commit is contained in:
Michal Pikulski
2025-10-17 13:18:33 +02:00
parent 78fad26ff5
commit 74339d7c47
11 changed files with 43 additions and 74 deletions

View File

@@ -82,17 +82,13 @@ namespace Minigames.DivingForPictures
if (onObstacleDestroyed == null)
onObstacleDestroyed = new UnityEvent<GameObject>();
}
void OnEnable()
{
// Register with the DivingGameManager for pause/resume events
DivingGameManager.Instance.RegisterPausableComponent(this);
}
private void Start()
{
// Register with the DivingGameManager for pause/resume events
DivingGameManager.Instance.RegisterPausableComponent(this);
DivingGameManager.Instance.OnGameInitialized += Initialize;
// If game is already initialized, initialize immediately
if (DivingGameManager.Instance.GetType().GetField("_isGameInitialized",
System.Reflection.BindingFlags.NonPublic |
@@ -104,7 +100,7 @@ namespace Minigames.DivingForPictures
private void OnDestroy()
{
DivingGameManager.Instance.UnregisterPausableComponent(this);
DivingGameManager.Instance?.UnregisterPausableComponent(this);
// Clean up any active coroutines
StopAllCoroutines();