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

@@ -1,6 +1,7 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using System;
using Input;
using Settings;
namespace Utility
@@ -66,6 +67,7 @@ namespace Utility
orientationCorrect = IsOrientationCorrect();
if (!orientationCorrect)
{
InputManager.Instance.SetInputMode(InputMode.UI);
ShowPrompt();
orientationCheckCoroutine = StartCoroutine(OrientationCheckRoutine());
}
@@ -77,7 +79,11 @@ namespace Utility
return scene.name == "Main Menu" || scene.name == "MainMenu";
}
private bool IsOrientationCorrect()
/// <summary>
/// Checks if the current device orientation matches the required orientation for the scene
/// </summary>
/// <returns>True if the orientation is correct, false otherwise</returns>
public bool IsOrientationCorrect()
{
switch (requiredOrientation)
{
@@ -121,6 +127,8 @@ namespace Utility
StopCoroutine(orientationCheckCoroutine);
orientationCheckCoroutine = null;
}
InputManager.Instance.SetInputMode(InputMode.Game);
}
private void CleanupPromptAndCoroutine()