- Home /
How to adapt to different aspect ratios?
Basically, so many asked this but no one managed to give a proper answer.After searching for hours and hours,I am putting my hope on you guys.
I made a 2D game at resolution 2:3. I have everything finished and I want to publish it now ( Iphone, Android and maybe other platforms),but I can't understand how this aspect ratio works.
I know it is the width / height, but this is not what I am interested in. The canvas scales automatically so that is good, but what about the sprites? How can I also scale the sprites?
I tried this on my Samsung S7 edge and I already have a problem with scaling and the position of the sprites.
So my question is, how do others do it? How should I handle this aspect ratio problem? Can somebody give some piece of code (that would be perfect) ? Is there a generic script one could use? Can it be done just by adjusting the camera size?(camera is orthographic) Why can unity scale the canvas according to screen size but not the gameObjects too?
I am an absolute beginner when it comes to this, so please leave consistent answers, otherwise it would be meaningless.
Answer by Luweno · Aug 14, 2018 at 07:27 PM
Hi! I've used the method described in [http://2sa-studio.blogspot.com/2015/01/handling-aspect-ratio-in-unity2d.html]. You just have to insert the script inside the Main Camera. It creates a public Inspector, where you'll type the desired Aspect Ratio. Given that it only works for 2D Games, I feel like it could help!
Your answer
Follow this Question
Related Questions
Android - Normalize touch position based on mobile screen size 1 Answer
How to make a 2D game resolution independent 2 Answers
Camera Aspect Ratio letter boxing 1 Answer
Force/Maintain aspect ratio of game/ add black bars on edges/ SOLUTION 0 Answers
Im having some problems with customs aspect ratios in builds what should I do? 0 Answers