Wait for correct screen orientation
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user