Alright, guys! I’ll try to explain to my best ability.
What I am trying to do:
I am trying to make a horizontal scroll-able list of images that all have the same size (1024x1024px). This list contains 1 to x images based on the state of the game.
All images should be correctly scaled to fit a %-value of the vertical screen size while still keeping their aspect ratio so that the image-list look the same on most/all screen sizes. The images should be aligned to the left side of the list (so if you only have one image in the list, it doesn’t appear in the middle of the list, but at the left side).
The list itself (we’re talking the scroll-able area) is re-sized to the content of the list (this is so that the player can scroll between images when the list is too long for the screen size, but that you can’t scroll “away” from from the images if you don’t have enough images to go outside the screen).
- Does this make sense? Should be easy, right?
How I have done it this far:
Step 1:
Created a panel that takes up the desired screen-space and set the anchors to the same position as the re-size-handles like shown here in Figure 1. It will contain the Scroll Rect-component and control its child panel.
Figure 1: This is the panel that will contain the other elements as well as the canvas.
Step 2:
Created a new child panel that stretches vertically to fill its parent with anchors and pivot point aligned at the left side like shown in here in Figure 2. This panel will be the parent of all the images in the list.
Figure 2: Here is the child panel.
To make sure that the children-images is placed correctly in line, this panel has a Horizontal Layout Group-component. Child Alignment is set to “Middle Center” and Child Force Expand is set to only work on the height of the images (check Figure 3).
I also added a Content Size Fitter-component on this panel with a Horizontal Fit to “Preferred Size” so that the panel it self expands horizontally, effectively giving me a bigger scrolling area as the list grows (check Figure 3).
Figure 3: The values of my Horizontal Layout Group and Content Size Fitter.

Step 3:
Created x number of child images that are set to Image Type “Simple” and Preserve Aspect to “true”.
The problem:
The images are not actually placed by the Horizontal Layout Group, but scaled. Even though the Image-component displays the image with the correct aspect ratio, the Rect Transform-component (in this case; controlled by the Horizontal Layout Group) is still stretched pretty bad (effect is of course worse the smaller the screen is because… pixels…).
I’ve tried to give the images a Layout Element-component, playing around with the Preferred Width to override this horizontal stretching. But because these values are pixel-based, I can make it look good on one screen size, on others I end up with pretty much the same problem.
I tried to give the images a Aspect Ratio Fitter-component, trying get the height to control the width of the image Rect Transforms. But because the Rect Transform is already controlled by the Horizontal Layout Group, that is not allowed.
I figured the Layout Element-component is what lets me make the exceptions in the parents layout controls. So I tried to extend the Layout Element-component with some tools that lets me define the values with percentage instead. But I’m no programmer… and the backend of the UI system is a little hard to get around, at least with all these layout group dependencies and Rect Transforms.
Figure 4: Here is how much wider than the image the Rect Transform has streatched.
Figure 5: When all my testing images are put in, this is how long the whole scroll-area becomes.
Have I done something wrong here? Can’t figure it out…
Just post if you need more info.







