- Home /
Autorotate ... but only on certain scenes?
For ios/android, imagine a game where, on your scenes A, B, C, only portrait is allowed (no autorotation allowed - twisting the phone does nothing, as with most games for example).
But, on your scenes D, E, F you can indeed autorotate (either portrait or landscape is allowed and it will autorotate - twisting the phone means unity will re-lay-out the screens/input, just as when say using a browser or whatever).
Has anyone found the best "formula" for doing just this?
I can imagine problems dealing with users twisting the phone during the moment of rotation animation or scene change etc :O
Maybe found it's problematic / not realistically possible?
There seems to be many gotchas with this and some undocumented stuffs.
In the "gotchas", that doesn't fic your problem?
Screen.orientation = ScreenOrientation.AutoRotation;
Screen.autorotateToLandscapeLeft = true;
Screen.autorotateToLandscapeRight = true;
Screen.autorotateToPortrait = false;
Screen.autorotateToPortraitUpsideDown = false;
You could call it in the method "OnLevelWasLoaded(int index)".