Tuesday, March 25, 2014

Unity3D mobile quicky noobie note.

So you are making something in Unity for mobile (lets say Android). You went ahead and selected your resolution in the preview window ("Game" window) And set your GUITextures with pixel inset values in the inspector. You might have even made a script that calculates things according to the screen resolution in X and Y to find ratios and what not. Then you deploy and you notice that something is off by a couple of pixels. You double check and things are ok but still get shifted in the screen.

So what gives? Well, Unity may have 1280*800 or other standard resolutions built in, but what the OS gives to the player once you actually have it running on the device is not exactly that. Remember it has the home bar. So that takes some pixels away from the real-estate, 28 pixels as far as I could tell in the case of 1280*800 screen resolution.

Just make a custom preview resolution of 1280*752 so you won't have to keep that in the back of your mind. I'm sure there are other a lot more elegant ways of solving this, this is the easiest thing I thought about.