I saw a thread about this a while back, but now I can’t find it, and I don’t remember if there was a solution.
I have a main menu in landscape orientation (auto-rotate, landscape only), and some levels that run in portrait orientation. I change the screen orientation in a main menu script BEFORE loading the new level as follow:
// main menu, going to portrait level
Screen.autorotateToLandscapeLeft = true;
Screen.autorotateToLandscapeRight = true;
Screen.autorotateToPortrait = true;
Screen.autorotateToPortraitUpsideDown = true;
Screen.orientation = ScreenOrientation.Portrait; // need this to force the change
yield WaitForSeconds(1.5);
async = Application.LoadLevelAsync("Level-Pulley");
Before doing anything with orientation, I put up a 2D graphic that fills the screen. I use the same code returning to the main menu, changing the rotation to landscape before loading the level, then setting it to autoRotation in the main menu Start function.
This works correctly going from the landscape main menu to a portrait level, but breaks going back. Returning from the portrait level to the landscape main menu, the orientation changes back and forth quickly, looks like every frame. This flickering continues for a few seconds until the main menu level loads. After that, the flickering occurs going FROM the main menu as well, and it hangs when I try to return from the portrait level again.
I’ve tried just about every combination of the various screen functions, and this is the best I can do. I’ve learned that the rotation needs to be changed BEFORE the level loads. Changing the orientation in the Start function is ignored. Also, orientation needs to be explicitly set to force the change. Setting it to autoRotation doesn’t do anything until the device is rotated.
Thanks. That’s only one line different than what I posted, and one of the MANY variations I’ve tried. Just like my code, it works only once. After that, it flickers back and forth until the scene changes, as I described above.
That link is the thread I was looking for, but that fix didn’t work either.
Well I have the same issue on iOS 9.1 (at least, maybe iOS 8 too)
I’m doing much simpler things, and I can’t change how it’s supposed to work since it’s a client’s choice.
What I do:
by default the app is launched in Portrait mode, works fine
when you enter some zone, I do Screen.orientation = ScreenOrientation.LandscapeLeft;, works
when you’re done, Screen.orientation = ScreenOrientation.Portrait; //works the first time
reenter the zone Screen.orientation = ScreenOrientation.LandscapeLeft; still works
when you’re done (again) Screen.orientation = ScreenOrientation.Portrait; but this time the app goes to portrait upside down instead.
if you do it a third time (landscape and back to portrait) then the app just goes rotating around endlessly (switching between various orientations every frame or so)
All along, I just hold the device still, it doesn’t matter in which position.
Unity 5.1.4f, with all rotation allowed in player settings
iOS 9.1, with portraitupsidedown NOT allowed in XCode 7
Did you or anyone ever managed to have an application on iOS 8 or 9 with a part in portrait and another part in landscape and go back and forth more than once without bug?