- Home /
Android auto rotation problem
Hi all, I'm migrating iOS game to Android. Recently I have 2 problems.
Player settings: Default orientation: Auto Rotation. Landscape right and left are checked. PROBLEM: Game starts portrait orientation and after splash image I can rotate my phone to get landscape mode. After that the game accepts only right and left landscapes as expected. I have a script that places the buttons according to screen width and height but it goes crazy because expected screen width gets height of the screen.
Splash image doesn't show full screen.
Any help appreciated.
I have tested with in the Android$$anonymous$$anifest.xml, but no luck.
Splash image is 1024x768 and it works all iOS devices. Currently I'm testing on Samsung note N7000 with android 4.1.2.
Landscape left or right only works as expected.
Still have no solution
Answer by supernat · Apr 08, 2014 at 05:26 AM
The splash screen being full screen is dependent on the aspect ratio of the device and the setting you have in the Player Settings. If you choose Center for the Splash scaling, and the splash image doesn't match your device's aspect ratio, then you will get letterbox sides potentially. If you have it set to Scale to Fill, it should always be full screen. Also, 1024x768 isn't a native android resolution for every device, so it will only fit on some devices, but that's why Unity provides the Scale options in player settings for the splash image. Android does not have any concept of a splash image, whereas iOS builds that into the XCode project. It does some extra manipulation/scaling to make it fit on a very small number of devices but also allows you to select multiple image sizes for your splash, one for each device resolution. Unity creates its own version of the splash screen for Android by presenting it in the main View on startup.
When are you retrieving the Screen.width and Screen.height values? If in the Start method, then they will be wrong once your device rotates after this and you need to retrieve them again. I would like to help with your question, but I'm a bit confused since you say Landscape left or right only works as expected. You want them to not work as expected? What exactly is the issue, you can't return to portrait mode?
Ty for your answer. I designed my game for landscape mode. So I don't want to it in portrait mode. 1. If I choose multiple Landscape Left and Landscape Right in player settings, the game begins in portrait mode. After loaded fully, it keeps portrait and when I rotate device It goes to landscape mode and it locks landscape right and left as I set up in the player settings in Unity. But problem is screen.width and screen.height as you said, that makes everything in my game goes crazy. 2. If I choose Landscape left or Landscape right only. Game launches in landscape mode and it doesn't rotate (it should have), everything is in their places.
Once again thank your answer. I develop games for iOS. This is my first Android game and I haven't got any problems like that.
I have tested Scale to fill, but it crops the image. So we took your advice to prepare multiple splash images. But my designer gave new splash image that has borders faded away to black. (Edges of the image faded to black)
Hi saruul. I think I understand better. Are you running the latest version of Unity? Have you tried this on multiple devices? The thing about Android is, calling OS provided methods can return one thing on one device and behave completely different on another one, so this could be an issue that Unity needs to fix via work arounds. I will run a simple test on my Nexus 7 to see what it does with this.