I am trying to work out how to support various resolutions for my Android game. I have come up with a solution, but do not know how to implement it.

Automatically, I am told that Unity vertically scales the screen to match the screen, leaving more room at the sides. How can I change this behaviour? I am hoping to shrunk the game down till it fits horizontally, and filling it the background above and below with more decorative features. How can I achieve this?

I'm sorry if there is an obvious answer, I'm quite new working with the Unity UI system.

If it makes it any easier, my game is heavily based on UI, and is locked in landscape.

BIG EDIT: I completely rephrased this question because it was so broad and messy.

  • \$\begingroup\$ By default, a Unity camera will show its entire vertical field of view, scaled to fit the full height of the display. So all devices will see the same slice of your game world from top to bottom. The width of the crop is adjusted to match the aspect ratio of the display, meaning a narrow display will show less of your game world side-to-side, and a wide display will show more. This can all be overridden if you want different behaviour (eg. with UI Canvas scaling modes). With that in mind, can you clarify what, if anything, you want to change about this behaviour? \$\endgroup\$
    – DMGregory
    Oct 24, 2016 at 3:59
  • \$\begingroup\$ Hey @DMGregory, you've answered one of my questions before! Thanks for you answer this time too. I'll edit my main post to reflect what I am trying to do. As a side question, what does Unity do to the resolution? The background in my test game is 2280 x 1440, but when I built it to my Android phone it was still a bit blurry. Is there something else I'm missing as well? Thanks again. \$\endgroup\$
    – Infergnome
    Oct 24, 2016 at 10:02
  • \$\begingroup\$ That's worth asking separately, as it can get a bit complicated. Textures (not UI images) are typically stretched or squashed to the nearest power of two size and saved in a GPU-friendly compressed format. Then on display, depending on how you've placed your background in the scene/adapted to display resolution, it may be displayed bigger or smaller than its native size. All of those things can degrade quality. Post a new question with details of your setup (and images, ideally) and we can suggest ways to avoid this. \$\endgroup\$
    – DMGregory
    Oct 24, 2016 at 12:05
  • \$\begingroup\$ Awesome. I'll do that if I have further trouble. I've been thinking further on this, and I've narrowed it down to two options. Choosing a vertical safe zone, with decorative features at top and bottom, would keep the images clear, but waste precious UI space. Vertical stretching would waste less space, but could make the images look pretty bad. Dou you have any ideas / suggestions for either? I imagine I will have to do some experimenting. Thanks! \$\endgroup\$
    – Infergnome
    Oct 24, 2016 at 12:23

1 Answer 1


Okay, so I think I've got this worked out, so I'm making my own reply. I attached this script to the main camera.

using UnityEngine;

public class AspectRatioController : MonoBehaviour
    public float targetWidth;

    void Start()
        Camera camera = GetComponent<Camera>();
        camera.orthographicSize = (targetWidth / camera.aspect) / 2;

In the Unity Editor, set the targetWidth as the width, in units, of your background. This will change the camera size until the background fits perfectly, leaving extra space at top and bottom depending on your aspect ratio.

As for the safe zone, I decided to make two scenes for every menu: one for wider screens, one for squarer screens. The wider screens have 3:2 backgrounds, with a 16:9 safe zone, while the squarer screens have 1:1 backgrounds with 4:3 safe zones.

I hope this can help other people.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .