While doing some research about resolution and scaling to different devices for a 2D top-down RPG game, I came across multiple posts stating that each individual object/sprite must be scaled via scripts and other complex solutions to what seems to be a simple problem. But I just tested my 4K resolution build with a variety of aspect ratios and resolutions on PC and see that Unity handles the scaling problem automatically, without a script. But since I’m a beginner, perhaps I’m missing something… Is it accurate to state that, for the most part, Unity scales down to any resolution automatically?
My general approach to the problem of scaling the game world (not the UI) for multiple devices is this: 16:9 is my most “extreme” aspect ratio that I will support. I am working with high-resolution sprites designed for 4K resolution in mind that will scale down to each device’s resolution. (Perhaps the device type will also dictate the resolution per build to reduce file size, so Android gets a 1920x1080 build and iOS gets a retina-scale build.) Since a wide resolution like 16:9 can display more elements on-screen than a 4:3 resolution, to resolve the issue of aspect ratios I will make the main game elements with which the user can interact with or see reside within a 4:3 aspect ratio “bounding box” that extends to the long side of a 16:9 resolution. This 4:3 resolution will then be the most square aspect ratio that I will support, making it the other “extreme” aspect ratio. Users with an aspect ratio wider than 4:3 will then be treated to more art elements, etc. that lie beyond the 4:3 bounding box, but they have no impact on the gameplay. Perhaps a “fog of war”-type mechanic can be implemented beyond the 4:3 bounding box to trivialize the outlying game elements even further.
Although I have also researched what to do with the UI elements, I have not given much thought to them yet. The simplest solution would be to also place such elements within a 4:3 bounding box, allowing all resolutions up to 4:3 to display them in much the same way. But it is not a very elegant solution, though on second thought, it could look good if executed well enough. The other way would be to place UI elements not by absolute values, but by percentages/fractions.
Before I commit any more time to development, I’d like to know if I am going about this the right way. What are your thoughts? Any additional ideas or advice?
You’re totally on the right track. Your world solution is similar to what many AAA games use (and professional TV broadcasting, too). On the UI front, you can keep everything in the 4:3 safe zone (what some TV channels do). That usually looks fine for menus but can look janky for HUD. HUD objects often work well with an edge-snap type approach (i.e. this element is 10% of the screen from the left edge and 5% of the screen from the top edge).
Thanks for the input.
Do you have any advice regarding different pixel densities? I can imagine a world looking tiny on a high resolution but small retina screen, for example.
You’ll generally want to have some sort of world scale/zoom level as part of your rendering. It sounds like you have that already. If so, you can set a default zoom level by looking at the device id. If you can categorize your most common devices as being phone/tablet/monitor/tv, then that’ll get you a long way. If you ship on Android, there are some APIs you can query about physical device size (not sure if Unity exposes any of them directly), or you could add a user option for choosing phone vs tablet vs TV.
Since I started with Unity and game development recently, I’m actually in the beginning stages of development, and I do not have such a “zoom” system in place. How would something like this work, exactly? Wouldn’t a zoomed in version of an iPad retina scene be cropped all around due to the zoom (compared to a 4:3 1024 x 768 17" screen, for example)?
Also, what device ID am I looking for in the SystemInfo reference page?
Zoom is usually just the camera moving in and out along Z. You can also do it in a 2D game if you have a transform that everything is parented under and you scale that transform.
Also, remember that resolution is not the same as your world size/scale. You probably think of your world in terms of tiles, and want to have, say, 10x10 tiles on screen at once. That should be true on an iPad 1 or an iPad Air, even though they are different dimensions. If you want to get really fancy, maybe 10x10 is too many for an iPhone, so you decided that all phones should be 5x5 tiles, but that should be the same regardless of if you are on an iPhone 3 or an iPhone 5. Make sense?
You may be wondering how to make art for a game like this. If a tablet is 10x10 that means that a tile on an iPad Air is much higher resolution than a tile on an iPad 1. That’s ok, usually you just build your art for the highest resolution display and then let the GPU scale it down for lower resolution devices.
As for device ID, you’ll want the name, model, and probably the type.
Sorry for the late reply – I could not get back to work until today.
Thanks for the additional insight. I’m going to get back to work with it in mind.