0
\$\begingroup\$

I have a ScrollView object in my project. It is set to Clamped.

Inside the ViewPort, I have Content and what I actually want to scroll, a TextViewMesh. The Content has a Content Size Fitter, with its Vertical fit set to Preferred Size.

The problem is, when I run it, and try to scroll, it does not scroll at all, in ScrollView to the current setting. If I set the ScrollView mode to Unrestricted, it scrolls to the infinity. What I am doing wrong? How can I set my ScrollView to scroll the text (which can vary in lenght)?

Screenshot

\$\endgroup\$
1
\$\begingroup\$

Your screenshot shows that Viewport has two children, Content and Description. You stated that Content has a ContentSizeFitter component. If your text is on the Description object, the ContentSizeFitter is not going to adjust its size for the text because Description is not a child of Content.

You may need to move Description to be a child of Content, and add a VerticalLayoutGroup component to Content.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Already tried that, and didn't work. Desctiption is not an object containing the text object, it IS the text object. \$\endgroup\$ – Fustigador Aug 27 at 7:35
  • \$\begingroup\$ Then you need to make Description a child of Content. The content size fitter on Content will not work if Description is not a child of Content. You may also need to add a VerticalLayoutGroup to Content after moving Description \$\endgroup\$ – Kevin Aug 27 at 16:46
  • \$\begingroup\$ I fixed it. Deleted Content, and now there is only Description, with its ContentSizeFitter. I didn't need the VerticalLayoutGroup, however, probably because there is only one element. Your answer put me in the right track. Thank you! \$\endgroup\$ – Fustigador Aug 28 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.