Unity) How can I maintain sprites aspect ratio?

Viewed 3275

enter image description here

In the editor, my game works fine But in android device, all images in my game are distorted by resolution.

In some answers, use the preserve aspect in Image component, but I think sprite renderer and image cannot be used at the same time

How can I solve this problem?

1 Answers

Images in different screen resolutions may stretch horizontally or vertically. To prevent them from doing this you can, first, add component 'Aspect Ratio Fitter' to the objects that stretch. There is 2 main modes there: Width controls height (width is always the same and height changes so that the object has the same aspect ratio) or Height controls width (height is always the same and width changed).

Besides, if your object are in Canvas you can set UI Scale mode to Scale with screen size in component Canvas Scaler. Then you can set the default screen resolution and it differs on a particular device, the objects in Canvas will change their sizes by themselves preserving initial appearance.

Related