Add size constraints for UIGridLayout

Recently, studio added some useful little objects to help streamline and enrich the UI development process, including ways to list items in spaced-out positions without coding it in through the use of UIGridLayout, ListLayout etc.

image

Within the GridLayout, you can set how big you want each cell to be in UDim2, including a Scale and Offset size property. The only issue is, since this is oft placed into a ScrollingCanvas object, they can become stretched and distorted when the CanvasSize changes size.

This makes GridLayout objects imperfect and lacking when it comes to this use case.

I could get around it by manually checking how many pixels wide the canvas is and setting the cell X & Y size to that, but that defeats the purpose of UIGridLayout.


(v How it’s meant to look v - I had to fiddle around with the cellsize at runtime to find the best option, but the moment I add a new item to the list, I would have to manually find a new cellsize value.)

What would be really useful is, like with other Gui objects, having the ability to lock the Scale factor to XX/YY. That means I can have uniformly scaled cells that scale up with the canvas size with ease.
image

Then, in this use case, I could set the constraint to XX, so if my cell size were {0.5, 0, 0.5, 0}, it would be perfectly square with dimensions half that of the width of the canvas!

7 Likes

Why don’t you just put a UIAspectRatioContraint under the grid layout instead?

2 Likes

While that fixes the size of the cells, they are still positioned far apart as if they are scaled massively. (I assume because it calculates the size of the cells then positions them first, then the aspect ratio constraint follows after but doesn’t update positions)

4ae575d66667f3a92565dad34ffa16f5

1 Like

You probably put the aspect ratios inside the objects themselves, but putting it directly into the UIgridLayout or UIListLayout wouldn’t have this issue.

7 Likes

Oh hey, that actually worked. Thanks a lot :smile:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.