[iOS 16] Screen Orientation fixed to Landscape Left but sometimes it rotate autommaticaly
Asked Answered
W

2

0

Hi,

Using iPhone or iPad with our Unity app we have seen that sometimes these devices rotate automatically the screen. We have fixed orientation Landscape Left on player settings and we change the orientation programmatically.

This can be happenning after upgrading to iOS 16.

Is there a solution for that?

Many thanks!

Walsingham answered 26/9, 2023 at 10:14 Comment(0)
A
0

@Walsingham - I seem to recall there is a known Unity problem related to the latest versions of iOS. Screen orientation changes sometimes occur even when a specific orientation is set in the Player settings. There is, however, a workaround you can try to implement.

Firstly, make sure you disable “Auto Rotation” in Player settings, while keeping only the Landscape Left checkbox enabled.

Then, try to enforce the orientation programmatically when your app starts and when it comes back to foreground after being in the background. Here’s an example of how you could do this:

void Start()
{
    Screen.orientation = ScreenOrientation.LandscapeLeft;
}

void OnApplicationFocus(bool hasFocus)
{
    if (hasFocus)
    {
        Screen.orientation = ScreenOrientation.LandscapeLeft;
    }
}

These methods should force the screen to return to the desired orientation whenever the app is started or brought back into focus. Do test it and let us know if it works.

Araucania answered 25/5, 2023 at 8:38 Comment(0)
D
0

It doesn’t work. I use Unity2021.3.19 and add this script. Unexpect orientation and screen rotations still occur in IOS16

Debroahdebs answered 25/9, 2023 at 3:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.