When I turn my ipod touch I can see black borders rotate around, how can I make my game rotate with it just so that its the correct way around to play?
I have tried various methods on the forums but they dont seem to work.
Same problem here: I do not want the ugly black frame - but I do want the keyboard to display correctly no matter what the orientation is. I’d say this is a bug - either in Unity or in iOS.
So, when you are using the keyboard but don’t want the ugly black-frame rotation it seems there’s currently no way to get both done; so having the black border is obviously less disturbing as having the keyboard show up with wrong orientation basically makes it useless (probably Apple would even reject a game that does this).
Originally, I thought I could “trick the system” by simply switching autorotate on before displaying the keyboard (or even before displaying screens that need the keyboard) - but unfortunately, that only fixes it when the player switches screen orientation again … so that also doesn’t make a lot of sense.
To answer the original question (which is much easier than getting rid of the nasty border without disabling proper usage of the keyboard):
Do something like this (one possible way is keeping currentOrientation as member variable and then checking whether it has changed on Update and change Screen.orientation in those cases - so watch out, this code is really just meant to give you an idea, it’s not copy’n’paste-proof ):
DeviceOrientation currentOrientation = Input.deviceOrientation;
switch (currentOrientation) {
case DeviceOrientation.LandscapeLeft:
Screen.orientation = ScreenOrientation.LandscapeLeft;
break;
case DeviceOrientation.LandscapeRight:
Screen.orientation = ScreenOrientation.LandscapeRight;
break;
case DeviceOrientation.Portrait:
Screen.orientation = ScreenOrientation.Portrait;
break;
case DeviceOrientation.PortraitUpsideDown:
Screen.orientation = ScreenOrientation.PortraitUpsideDown;
break;
}
Of course, there’s also ways to rotate the camera smoothly (switching Screen.orientation “switches” to the new rotation - it doesn’t smoothly rotate). However, I don’t think you’ll manage to get the rotation synced with the ugly black frame.