I need to add X objects to a scrollview. I do it like this:
GameObject statsObject = Instantiate(instance.statsObjectPrefab);
statsObject.transform.SetParent(statsParent.transform);
statsParent
is the content container if the scrollview.
Scrollview
---- Viewport
-------- Content // This is statsParent
In the pause I see that then objects are added successfully, but they all overlap and no scrollbar is visible.
The content has a content size fitter and a vertical layout group, but I tried now all settings and the result is always the same.
I use Unity 2019.2
SetParent(statsParent.transform, false)
? \$\endgroup\$ – DMGregory♦ Jun 21 '20 at 2:03LayoutRebuilder.ForceRebuildLayoutImmediate
after adding the object? \$\endgroup\$ – Safa Jun 21 '20 at 9:13