- Home /
Manually setting Screen.orientation breaks AutoRotate
I have 2 scenes. The first rotates between portrait up and down. The second should rotate between the 2 landscape orientations. When I change scenes I call this code:
Screen.orientation = ScreenOrientation.LandscapeLeft; // This line breaks Auto Rotation
Screen.autorotateToLandscapeLeft = true;
Screen.autorotateToLandscapeRight = true;
Screen.autorotateToPortrait = false;
Screen.autorotateToPortraitUpsideDown = false;
If I set the screen orientation to be landscape left the scene does not rotate anymore when I flip the device.
Bump. I'm having the same issue, this is on iOS with the 4.6 beta (b20). Rotation works great until I force it to a certain setting in script; after that, auto-rotation no longer works.
In addition to that: when I force-orient the screen to landscape mode, background the app and then come back, the whole frame seems to rotate 90° with half being rendered outside the screen bounds, which renders the app unusable. Setting Screen.orientation to any value doesn't fix this. Anyone have any ideas?
What kennyd-itp has written above is also the same issue Im facing. Damn ios8 view controller changes has broken the orientation aspect of Unity which was totally fine in ios7.
Answer by ThumbSnail · Apr 29, 2015 at 02:33 AM
Setting Screen.orientation = ScreenOrientation.LandscapeLeft; forces the screen into landscape mode, but it also prevents the screen from rotating.
Thus, after setting the autorotate bools, you'll need to include this line:
Screen.orientation = ScreenOrientation.AutoRotation;
In your case, it should now rotate between the landscape orientations only.
Your answer
Follow this Question
Related Questions
Loading Portrait Scene from Landscape crashes the app 0 Answers
iPhoneKeyboard question... again! 0 Answers
When are Screen.width and Screen.height updated after changing the Screen.orientation value? 0 Answers
Accelerometer Auto rotate Issue 2 Answers
Splash Screen Orientation is incorrect at start app. 0 Answers