Wait for correct screen orientation

This commit is contained in:
Michal Pikulski
2025-09-30 13:13:37 +02:00
parent c640be7d9c
commit f1f4234c2a
7 changed files with 175 additions and 13 deletions

View File

@@ -74,9 +74,38 @@ namespace Minigames.DivingForPictures
}
private void Start()
{
// Find DivingGameManager and subscribe to its initialization event
DivingGameManager gameManager = FindFirstObjectByType<DivingGameManager>();
if (gameManager != null)
{
gameManager.OnGameInitialized += Initialize;
// If game is already initialized, initialize immediately
if (gameManager.GetType().GetField("_isGameInitialized",
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance)?.GetValue(gameManager) is bool isInitialized && isInitialized)
{
Initialize();
}
}
else
{
Debug.LogWarning("[ObstacleSpawner] DivingGameManager not found. Initializing immediately.");
Initialize();
}
}
/// <summary>
/// Initializes the obstacle spawner when triggered by DivingGameManager
/// </summary>
private void Initialize()
{
CalculateScreenBounds();
StartSpawning();
Debug.Log("[ObstacleSpawner] Initialized");
}
private void OnDestroy()