UIGridLayout Does Not Center Objects Passed Row 2

Recently, @Razuatix and I have been working on new UI for our front page game, Tower Defense Simulator, and have stumbled across an annoying problem. For a grid based buffs display, we wanted to utilize a UIGridLayout but ran into an issue of objects passed row 2 not aligning in the center.
05c302d23853583dbbbbf2aca9013d67

But when it only has 1 row, it works as intended.b5ad190e89f103d5ae72d164d6d9473f

I have searched if this is an error on my part but it turns out its intentional.
According to this post, Roblox staff have just said, “just remake it from scratch”.

Although possible, it would be very inefficient. Instead of being able to toggle a gui object’s visiblity on and off, we’ll have to store all the objects in an array, and shift parents around using multiple UIListLayouts.

To fix this issue for us and all other developers utilizing UIGridLayouts, a “Center” option for the StartCorner property should be added. It already exists for the first row.

14 Likes

Middle isn’t a corner so this doesn’t make a whole lot of sense to add to StartCorner enum…

In general you should avoid titling/writing your post as a specific API suggestion – instead I would title it after the problem you’re needing to solve. Makes it easier to find again for people in the future with the same problem but don’t have the exact same proposed solution.

4 Likes

I don’t think this is a valid use of UIGridLayout - centring rows as you describe allows you to ‘break out’ of the grid when there’s rows of different parity. This is not a grid:

What you’re actually looking for is rows of items stacked vertically. That’s achieved by grouping the items into horizontal rows (using a horizontally oriented UIListLayout for each), then stacking those rows separately (using a vertically oriented UIListLayout).

If you really want this functionality in a single layout instance though, I’d suggest not tacking it onto the UIGridLayout API. I recall there being a UIInlineLayout for a while internally, which would achieve what you want, but not sure what happened with that or if it’ll ever be released.

6 Likes