- Home /
Android orientation issue
My game is in landscape mode however on Android sometimes my width/height are reported as reversed which creates all sorts of issues (some that I control and could fix, like choosing texture quality, but some that I don't control like tk2d camera anchor positions).
The .width and .height properties on Screen have no setters. Any ideas on fixing this?
Update: To reproduce this on my Nexus one, I have it plugged in, with the screen turned on but the lock screen still active (it's set not to sleep while charging). Build&Run from within Unity will start the game even though the screen is locked and will incorrectly make it get the portrait resolution of my launcher.
Answer by vividhelix · Oct 05, 2013 at 05:01 PM
This seems to be working:
if (Screen.height > Screen.width)
Screen.SetResolution(Screen.height, Screen.width, true);
Put it in a Start method in a script and change the script execution order to be run first before anything else.
Your answer
Follow this Question
Related Questions
Screen.width and Screen.height sometimes flipped for Android 1 Answer
Do screen.width and screen.height get updated depending on screen orientation on Android? 1 Answer
Screen.width & height not updated after screen rotation 1 Answer
Unity 3.5.7 Android Screen returns the wrong value? 0 Answers
Android screen orientation: why am I getting wrong screen size values? 1 Answer