Force scene to be LandscapeLeft or LandscapeRight
Hi!
I have a scene which is to be displayed in LandscapeLeft OR LandscapeRight, I can currently have it force LandscapeLeft however when the device is already in the LandscapeRight mode before the scene is loaded; it switches to Left regardless (It cannot also switch to LandscapeRight when the scene begins in LandscapeLeft either).
I have currently tried messing with the AutoRotation settings on both Unity and Xcode with no luck, I have tried using the following ;
Screen.autorotateToPortrait = false;
Screen.autorotateToPortraitUpsideDown = false;
Screen.autorotateToLandscapeLeft = true;
Screen.autorotateToLandscapeRight = true;
Screen.orientation = ScreenOrientation.AutoRotation;
And tried to set up an event using code such as;
if (Input.deviceOrientation == DeviceOrientation.LandscapeRight)
Screen.orientation = ScreenOrientation.LandscapeRight;
(Whether I'm wrong with the whole "Input" or "Screen" parameters?)
However it doesn't seem to take any effect, whether I'm calling it in the wrong method or its something clearly obvious; any help would be greatly appreciated!
Thanks!
Have you set landscapeLeft and right in unity PlayerSetting?
Yeah, shall I apply it only on the Unity PlayerSetting and not in the xcode settings? whether the ones messing with the other, I'll give that a try
When you set this settings in Unity, make a build and open it in XCode it should be already set.
Answer by Liam_B · Sep 15, 2016 at 08:40 AM
I've got it to work so the orientation locks to landscape-left/right, however if the screen is already in portrait/portrait-upsidedown then it will stay in this orientation until it has been rotated rather than automatically rotating to the supported orientations of the scene.
I'm guessing I'll need to set some sort of event to trigger it to change, however the previously mentioned way I tried (see above) doesn't seem to have any effect; I'm probably wrong somewhere.