- Home /
What are some strategies for supporting BOTH landscape and portrait mode on mobile?
I'm trying to create a game that is a top-down scrolling racer. Because it's top down and not side-view, gravity isn't a factor and the game should work fine in both landscape and portrait mode.
I want to enable that option and essentially have the game run the same way in both modes, but have the UI rotate according to the orientation.
The problem I'm having is that all my code was written using the assumption that the game would only be either landscape or portrait, which means that things don't rotate like they should when I change orientation. This is because obviously when you rotate the screen, things like positive X ALWAYS face towards the right side of the screen. In order to support both orientations, I'd need a way to tell Unity that positive X should now be the top of the screen instead (i.e. flipping from landscape to portrait).
Some things I was considering were asking the native device OS what orientation we were in, and then if we detected a change to portrait mode, actually set the Screen.Orientation property in Unity back to landscape so the positive X is preserved. Then manually rotate the UI to work for portrait.
That sounds pretty hacky though. Short of coding all my logic to support different axes, what are some strategies people have used to accomplish this kind of thing?
Illustration:
Answer by alok.kr.029.hotmail · Aug 26, 2014 at 11:30 AM
what I have did is set two different screen for the landscape and potrate with a single main character and checked if the device is in landscape or not and accordingly set active the screens .. http://docs.unity3d.com/Manual/MobileAdvanced.html
I am also searching for the same ans
So far this is what i am doing but i am curious to know if it has better way (especially with new ui system from 4.6).
Because the major headache with this approach is if we need to maintained two seperate copies of UI (one for landscape and one for portrait). When there is any changes required to do then our work get doubled :(