Need to vertically space buttons in scripting C#

I have a prefab and I need to clone that prefab vertically every 100 units from the top. For instance the first clone would be 100 units from top, the second clone would be 200 from the top, 300 from the top etc. The all the prefab are placed on a panel, which serves as a menu for my project. And the menu is scrollable, so some of the clones wouldn’t be seen unless the user scrolls. The problem I’m running into is I’m not sure how to position each clone vertically down (i.e. 100, 200, 300 etc). I can’t hardcode the values because they’ll change depending on the number of cloned items. Is there a method/function that I can use?

Hi,

Like @Cherno said, use Vertical Layout Group (on the parent that contains the objects) and Layout Element (on the children) … and the use the spacing property :slight_smile: