1
\$\begingroup\$

I have followed steps from this tutorial site to create dynamic scrollable vertical layout. I am trying to show 10 prefab buttons in a scrollview dynamically. I can see buttons at runtime, but they are overlapped.

enter image description here

ScrollPanel:

enter image description here

Content Container

enter image description here

I am probably missing some components tweaks. Or problem is due to anchors? Please guide me to resolve this issue. Thanks.

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

Set ContentContainer as the item's parent instead of ScrollPanel. Make sure your Scroll Rect has its Content property set to ContentContainer

Most likely you'll want a line like this one after instantiation:

LevelListItem.transform.SetParent(ContentContainer.transform, false);

See another post I wrote about setting up items dynamically.

\$\endgroup\$
0
2
\$\begingroup\$

The panel with the VerticalLayoutGroup has to be the parent of the objects you want to arrange within it. In your object tree it appears to be their sibling.

When you instantiate the LevelListItem buttons, make them children of the ContentContainer, not the ScrollPannel.

It also appears like you deleted the horizontal and vertical scrollbars of the standard ScrollView (or never had them in the first place because you created the ScrollView manually instead of from the "create new object" context menu. You shouldn't do that unless you know what you are doing). Without these there is no way to actually scroll it. When you want to hide them (always or only when they are unnecessary), then there is a property for that on the scrollbars.

\$\endgroup\$
0

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.