Add an element to the top of a vertical box

I want to be able to add a new element to a vertical box at runtime and it at the top while the other elements shift down

1 Like

Hey there, does it have to be a vertical box? You can do this easily with Grid Panel since you can control the indexes. Afaik you can’t do that natively with vertical box, but you can kind of hack it. After you add a child into the vertical box you save all of the items into an array and you clear the vertical box, invert the array and readd them again. It’s not pretty but it works.

1 Like

I was able to do it with the grid panel.
Thanks for the help:)

2 Likes

You are welcome :slight_smile:

This is an old thread but I suppose this may come up in a google search someday.

I had a similar problem with popup messages in my game, the way that I “solved” the problem is that I set the scale of the vertical box to -1. This resulted in the children to be flipped vertically but I solved that by setting the scale of those widgets to -1 as well. Now any new elements that are added will appear to be added at the top.

4 Likes

Here’s a simple workaround:

  • Add another vertical box as child to the vertical box and set scale of the child vertical box to -1 along Y
  • Add child widgets to this vertical box and set each child’s scale to -1 along Y

Hope that this helps