Unity UI图像中心裁剪

时间:2017-02-25 10:53:42

标签: android image unity3d unity5 unity3d-2dtools

我正在使用Unity中的listView项目并坚持在UI Image中正确拟合图像。我使用Preserver Aspect Ratop尝试了多种方法,几乎​​所有东西都使用填充图像类型,但无法让它看起来很好。在android我们称之为中心裁剪我想要实现的目标。第一张图片是Preserve Aspect,而第二张图片没有它。  Image with Preserve Aspect but you can see you empty space at top and bottom that looks weird as compared to square images (there are some)

Image without Preserver Aspect

我该怎么做才能实现它。

谢谢。

1 个答案:

答案 0 :(得分:1)

使用2张图像,这是我能想到的一种方法。外部图像设置为所需大小,并具有Mask组件:

enter image description here

将内部图像设置在外部图像的中心并缩放以适合外部图像(以编程方式或手动方式)。它将被外部图像的蒙版裁剪,并仅显示您想要的区域。 / p>

enter image description here