How to adjust positions of the sprites to different screen factors?


I’m creating a 2D game with sprites located evenly on the bottom of the screen. Everything works fine until I test the game with different aspect ratios: the sprites are no longer spaced evenly because the size/resolution of the screen changes.

I know I could check the screen size and position the sprites using a script but I’m wondering if Unity has any built-in functionality to keep the sprites “anchored” regardless of the screen resolution and the aspect ratio. By “anchored” I mean that when a sprite is at 2/3 horizontal distance, it remains at 2/3 no matter the aspect ratio of the screen.


That certainly exists for GUI elements. I’m aware of no such built-in thing for sprites that aren’t being hooked into the GUI (as with an Image).

Are these sprites actually part of a GUI layer? If so, you could switch over to using Image and get the kind of anchoring you want.

NGUI might have a feature like that and I don’t think it uses the traditional GUI infrastructure.

If all else fails, it probably wouldn’t be that hard for you to write a single unity behavior called something like “ManagePositionAndScaleByScreenSize” that encapsulates the concept you just mentioned (tracking resolution and dealing with it yourself).

Thanks Max for your answer. My sprites are a part of gameplay. They have colliders etc. They are not hooked into the GUI.

Writing a Unity behaviour is a good idea. I will go for that.