Ask about the screen solution configuration in the 2D games

Hello everyone,

I’m a beginner in Unity. I have read and practiced some tutorial articles about creating 2D game in Unity.

For mobile devices, I know that I need to build my games to iOS and Android mobile devices. However, how we can setup the screen solution (is it Camera ?) in Unity so my games can fit mobile devices ?

Could you please share some useful advice or links about this with me ?

Thank you so much.

Hello there!

Your actual problem is a bit unclear, but i’ll see if i understood what you want.

First of all, you must switch your project platform to the one you want to build to. For this, you go to File->Build settings, then choose the platform you want to build to and click the switch platform button (i’ve attached a pic of how the screen should look for android after you switch).

This should be the first step, now, secondly, you have to choose a screen size. For that, in your Game view, from the free aspect dropdown, select whatever screen size fits your project (i’ve attached another pic for you to see where to pick it).

Now lastly, designing a perfectly scalable UI for mobile is quite the challenge for a lot of people with Unity, but here are some links. You need to learn about the Canvas and how anchors work

Designing UI for multiple resolutions (official docs): Redirecting to latest version of com.unity.ugui
Another nice tutorial for scaling here: Unity UI Tutorial: Canvas and Scalability - Cat Trap Studios

Good luck with your projects!

1 Like

Thank you so much,

My purpose is my game can play on all mobile devices with difference screen solution (e.g. iphone 5, 6, 7 …).

I have read the article at https://blogs.unity3d.com/2015/06/19/pixel-perfect-2d/

The author has created a PerfectPixel and add it into MainCamera to calculate orthographicSize.

Your link is for using Canvas, we can use it for some game projects ?

Thanks.

3157300–240169–PerfectPixel.cs (1.76 KB)

Are you making a pixel art game?
Because that article only talks about how to make pixel art sprites look better on Unity’s ortographic camera.

You don’t need anything to scale sprites to multiple screen resolutions, Unity does that automatically for you.
Just drag a new sprite onto the scene, and then make the game view bigger. You’ll see that it scales.

The problem with different screen sizes is the User Interface (UI) → buttons, menu items and so on. Those don’t really scale, and you must use a Canvas to anchor and scale them properly. Don’t worry about the actual in-game art, if you’re using Sprites, then they will scale by themselves. As for the UI, the links i provided should provide you at least with some insight on what to look for.

1 Like

Hi GabiMar,

Thank you so much for your help.

1 Like