- Home /
Making a scrollable list with ScrollRect, GridLayoutGroup and ContentSizeFitter. How to make it start at the top?
Hey guys! UI question:
I'm trying to make a menu that is scrollable vertically and has a dynamic amount of items, with the items starting at the top of the screen. I found a pretty close way to do it which is having a ScrollView object with a ScrollRect component, a grid object as its Content, and items as children of the grid. The grid has a GridLayoutGroup and a ContentSizeFitter.
The problem is that the list is always centered vertically in the middle, and when items are added, it grows both up and down, even if the anchors of both the ScrollView and the grid are at the top, and Start Corner and Child Alignment of the GridLayoutGroup are Upper Left.
Is there a way to make the list start at the top and grow towards the bottom only?
To show the problem here's a test project that I downloaded and modified: https://drive.google.com/file/d/1aMZsK9QuGuJs4sUmqid2Fy8-qx29-KHK/view?usp=sharing
Thanks a bunch!
Answer by AhmadSannan · May 13, 2018 at 06:02 AM
This question has been answered here:
https://answers.unity.com/questions/1089307/scroll-rect-starting-in-the-middle.html
all you need to do is to set the 'Y' Pivot of your items container to '1' if you want it to align to top
Your answer
Follow this Question
Related Questions
Why doesn't childing a gameobject to GridLayoutGroup at runtime align it properly? 1 Answer
Changing the scale of the scroll view 1 Answer
ScrollRect bahaving weirdly 1 Answer
Calculating normalized horizontal position based on container size with fixed item size 1 Answer
Updating UI after resizing grid 0 Answers