- Home /
Scrollable area keeps resetting?
I'm trying to create a scrollable UI element and every time I do, when I go to scroll, the list scrolls down as I spin my mouse wheel, but as soon as I stop, it rubber bands back to its original position.
I have a canvas and under that I have panel1 with a mask and a scroll rect. Under that is another panel2 which is the content of the scroll rect and has a content size fitter with vertical fit set to preferred and a layout element to set the preferred height. Under that are a bunch of panels that I want to be scrollable.
Also, whenever I hook up my scrollbar to the scroll rect, the scrollbar handle fills the entire scrollbar even though there is content that extends past the scroll rect.
Can anyone explain what's going on here?
@homer_3 Can you show me the screenshots of Scroll rect and its child contents ?
@saud_ahmed020 made a video of what I'm doing and seeing https://www.youtube.com/watch?v=Sfd4XkbLui$$anonymous$$
I had the same problem. The content size fitter was the culprit for me.
Once i removed this component and manually set the size of the content, the scroll rect worked for me.
Try that.
Please always post screenshots, it is hard to visualise everything in the head.
Answer by KuR5 · Jun 04, 2016 at 03:58 PM
WRT your example, just add one more component named "Grid Layout Group" to panel2. In that component :
set Start Axis to Vertical
set Constraint to Fixed Column Size
set Constraint Count to 1
Set value of Cell Size with preferred width and height of child
Further remove "Layout Element" from all of the child of panel2.
Answer by Lasutriv · Mar 02 at 09:52 PM
You can also add the "Content Size Fitter" component to your content and then if it's a vertical scroll then set the property "Vertical Fit" of "Content Size Fitter" to "Preferred Size" and likewise for the horizontal fit.
Your answer
![](https://koobas.hobune.stream/wayback/20220612082117im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Check if visible in UI Mask 2 Answers
How can I create a Multi line Input Field with Scrollbar? 0 Answers
Smooth scroll snap? 3 Answers
Why is my scrollbar not working? 4 Answers
Making resizable window like a Microsoft Windows OS's folder window 0 Answers