I have a GameObject
with RawImage
component displaying an Image using Texture
.
The image is squeezed to the size of the object and changing it's original ratio.
How can I tell the image in the texture to CropCenter
? (like in Android for example)
Here is how I do with landscape images :
RawImage
element called "Mask" (works withUI > Image
component too)UI > Mask
component to itRectTransform
:Layout > Aspect Ratio Fitter
to the Smurf image and set theAspect Mode
to "Height Controls Width" and theAspect Ratio
to the desired value (16/9 for example)Check the image : Parent called "Mask" and your smurf image called "Image"
For portrait images, the
RectTransform
values :The
Aspect Mode
of the child must be set to "Width Controls Heigh"