Skip to content

Instantly share code, notes, and snippets.

@Enigo
Created February 6, 2021 20:33
Show Gist options
  • Save Enigo/df42edfc4b2603e550720fd2a97ba75f to your computer and use it in GitHub Desktop.
Save Enigo/df42edfc4b2603e550720fd2a97ba75f to your computer and use it in GitHub Desktop.
public class OrientationSetter : MonoBehaviour
{
private void Awake()
{
SetupInitialOrientation();
}
private static void SetupInitialOrientation()
{
if (PlayerPrefsUtils.HasOrientation())
{
if (PlayerPrefsUtils.IsPortrait())
{
if (Screen.orientation != ScreenOrientation.Portrait)
{
Screen.orientation = ScreenOrientation.Portrait;
}
}
else
{
if (Screen.orientation != ScreenOrientation.Landscape)
{
Screen.orientation = ScreenOrientation.Landscape;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment