Cristian Garcia
Cristian Garcia

Reputation: 9859

Vertical Layout Group with Images of Different Ratios in Unity 4.6

How do I create a vertical layout group where all images have the same width (easy) but each has a height that respects its aspect ratio?

I basically just want a vertical wall of elements, some of those elements are images, and each image should look good.

Upvotes: 1

Views: 5536

Answers (2)

Zwander
Zwander

Reputation: 382

A little late, but for those finding this while searching:

The AspectRatioFitter will adjust the height based on the width of an element, allowing it to fit nicely into a VerticalLayoutGroup. See this forum post

Upvotes: 0

Requios
Requios

Reputation: 76

Make sure to toggle on Preserve Aspect Ratio on all your images.

If that doesn't help, try this: For each element in your wall, you can add a Layout Element component, where you can define it's preferred width and height.

You might also have to turn off Child Force Expand on your vertical layout group.

Upvotes: 2

Related Questions