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?

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.

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.