Mobile responsiveness with non-ui objects

Hi everyone ! :slight_smile:

I have a concern for a time now and I just don’t know what is the best option. I’m currently developping a mobile game in which you can control a circle and move around on your screen by dragging your finger.
However, I would like its size to be responsive, i.e. adapting to the screen size, getting bigger if the screen is bigger, etc.

My logical approach is to put in inside a UI Canvas whose anchors and sizes are relative to the screen. However, it seems a bit odd to put a gameplay element inside the User Interface, I feel this is not the correct way to do it.

I have considered applying a size by script with data such as Screen.width & Screen.height, thus letting my circle as a gameobject outside the UI, but I don’t think it is the best solution. What do you think is the best thing to do ?

Thank you very much

Adapt your camera’s orthographic size with the resolution.

1 Like

Hi, thank you for your answer.

But when I set a fixed size on my gameobject, will it resize automatically thanks to the camera ?
For instance let’s say I have my circle of 300x300px for a 720x1280 resolution. If I change the resolution to a bigger one, it will automatically change the size of the circle ?

Thank you

Yes. Check out something like this to get you started: mobile - How do you handle aspect ratio differences with Unity 2D? - Game Development Stack Exchange

Thank you very much, I will look into it ! :slight_smile: