- Home /
Android Resolutions Independent
Hi! I started with unity some weeks ago. Im trying to make a simple side-shooter 2d game, i had set the camera with a script to 1280x720 so i can test it with my phone on landscape orientation.
There are a lot of resolutions for android, how should i work around this for not getting sprites scaled or off screen?
Thanks :)
It's not just the HUD. There's also the problem of the camera size. A 1200x600 screen will show more gameplay area than a 800x600 screen. You need to adjust the camera size according to the resolution.
Answer by chariot · Jan 19, 2015 at 11:36 AM
Try to use orthographic projection for main camera and set ur gameplay field mostly on center, not to borders of screen. Also you can use some sort of scale system by scripting it, but it can cause some issues with visualisation of your project. So just turn out your gameplay field out of screen borders. For GUI u can use
/* Screen.width & Screen.height example */
// JavaScript
function OnGUI () {
GUI.Box (Rect (0,0,100,50), "Top-left");
GUI.Box (Rect (Screen.width - 100,0,100,50), "Top-right");
GUI.Box (Rect (0,Screen.height - 50,100,50), "Bottom-left");
GUI.Box (Rect (Screen.width - 100,Screen.height - 50,100,50), "Bottom-right");
}
See also http://answers.unity3d.com/questions/352738/gameobject-width-in-screen-space.html