- I am adding items dynamically into a Layout Group and I cannot set a correct Spacing.
- I cannot modify the Width and Height values since they are grayed out and they are driven by Layout Group.
When UI items are children of a parent GameObject that has a Layout Group component, this component prevents the Width and Height properties of the UI Items from being modified via the Inspector, in order to be driven by the Layout Group in runtime.
You can override the Width and Height values by adding a Layout Element component in your item. Next, override automatic values set by the Layout Group with the values that you need.
This article applies to Unity versions 5.0+