- Home /
Why is my vertical layout group not spaced correctly?
I have a scroll view panel that contains a vertical layout group of prefabs that I instantiate and populate via a script. The prefab itself has a horizontal layout group to fit text boxes of different sizes.
As you can see in the screenshot, There is strange extra spacing on the left side of the scroll view panel. There is also strange spacing between the prefab rows. Interestingly I can minimize it by setting negative spacing in the vertical layout group.
However, I can't do anything about the spacing on the side, which isn't aligned with my header panel above the scroll view.
It's been driving me insane the past couple days. Please send help.
You should add screenshots of the prefab, at least the RectTransform. It could be you have a pos x with some values. Second the LayoutGroup, coz maybe you need to tick the control size Height/Width. Also, spacing/padding may be set and you did not notice. Having layout group on each item, plus layout group on the parent is about to get heavy on mobile, you'd be better setting values of the anchor points.
Answer by OzyBear · Mar 16, 2020 at 12:30 PM
Sorry for necroing this post but in case someone having the same problem, did you check padding settings under vertical layout group? Padding left value may be the reason for extra spacing on the left side of the scrool and spacing may be the reason for spacing between prefab rows. Setting them to zero may solve this problem.