Mobile Device Resolution Quirk

So I have been working on making ‘Ball and Cup’ resize correctly for the several different resolutions that android supports.  I was fortunate enough to run across this great video tutorial.

It showed me how to properly size GUI for different iOS devices.  As of the writing of this blog post iOS has only 4 different resolutions so it is pretty simple to write a function to ‘return Screen.height==640;’ to check the resolution of the current device.  Simple enough, however there is a bit of an issue if the user is holding the device portrait when you expect them to be holding it landscape for your game.  Sometimes even though you deselect the option for portrait in the Unity Player settings it still loads as a portrait game.  Anyway my solution was as follows.

private var screenHeight:int;


It is a pretty straight forward solution and now I am checking against the variable ‘screenHeight’ instead of the parameter ‘Screen.height’.  If you know a better way let me know.  This is pretty simple though.

Leave a Reply

Your email address will not be published. Required fields are marked *