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

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!

@ArnauKokoro - 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.

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