Managing multiple backgrounds and resolutions in a 2D game?

So my question is, what’s the best way to manage backgrounds in a Unity 2D game & have them resize correctly for different screen aspect ratios and resolutions, while keeping the build size in check?

We just launched our first game Poogeon and we’re working on an update that will incorporate different backgrounds. Currently we have ~1080px tall images of a single background in 5 aspect ratios (3:2, 4:3, 15:9, 16:9 & 16:10) and we’re using a script to set the appropriate background image sprite based on the device. We’re using a UI canvas to hold the background as it allows us to easily set the image to aspect fill. While this works, it isn’t very efficient as we have 5 high res image files just for one background, so if we add more then the build size is going to become massive very soon. Also, ideally I would like to use a standard sprite renderer & not a UI image component to hold the backgrounds, as I need it to be affected by camera shake.

iOS: https://itunes.apple.com/app/id1093040868
Android: https://play.google.com/store/apps/details?id=io.noarguments.poogeon

You could try using an Aspect Ratio Fitter component. The Aspect Ratio Fitter will make your image fit inside the Canvas based on what you choose. So it could fit vertically or horizontally and crop, or both and crop etc.

Alternatively you could lock to an aspect ratio and blackout the rest, or add a permanent menu if the screen is wide enough.

1 Like