Update the rotation enforcement to automatically lock device into

desired orientation.
This commit is contained in:
Michal Pikulski
2025-10-24 16:26:23 +02:00
parent 5a85a602bd
commit cc797f09ef
3 changed files with 113 additions and 210 deletions

View File

@@ -13,7 +13,6 @@ using UI.Core;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Playables;
using Utility;
namespace Minigames.DivingForPictures
{
@@ -169,26 +168,7 @@ namespace Minigames.DivingForPictures
GameManager.Instance.RegisterPausableComponent(this);
}
// Subscribe to SceneOrientationEnforcer's event
if (SceneOrientationEnforcer.Instance != null)
{
// TODO: This is a bit of a hack to make sure the game is initialized after the orientation is correct
SceneOrientationEnforcer.Instance.OnOrientationCorrect += InitializeGame;
SceneOrientationEnforcer.Instance.OnOrientationIncorrect += Pause;
// If orientation is already correct, initialize right away
// This prevents issues if the orientation was already correct before subscription
if (SceneOrientationEnforcer.Instance.IsOrientationCorrect())
{
InitializeGame();
}
}
else
{
Logging.Warning("[DivingGameManager] SceneOrientationEnforcer not found. Initializing game immediately.");
InitializeGame();
}
InitializeGame();
CinematicsManager.Instance.OnCinematicStopped += EndGame;
}
@@ -197,12 +177,6 @@ namespace Minigames.DivingForPictures
// Unsubscribe from events when the manager is destroyed
PlayerCollisionBehavior.OnDamageTaken -= OnPlayerDamageTaken;
if (SceneOrientationEnforcer.Instance != null)
{
SceneOrientationEnforcer.Instance.OnOrientationCorrect -= InitializeGame;
SceneOrientationEnforcer.Instance.OnOrientationIncorrect -= Pause;
}
// Unregister from GameManager
if (GameManager.Instance != null)
{