Properties review on UIGridLayout

Hi there! I oftenly use UIGridLayout and I’ve seen some help requests asking for example “How do I put equipped pets first in a list”. I’ll just select the main properties. This review is oriented towards beginners but there’s no problem if you wanna read it and refresh your knowledge.

Ok, first we have the FillDirection;


This determines wether the childs are filling vertically first or horizontally first.

Then we have the SortOrder;

When set to “LayoutOrder”, the filling system will prioritize the childs that have a smaller LayoutOrder value. Now that’s how you make equipped pets come first. If the first child’s LayoutOrder is 1 and the other childs is up than 2 then, the first child will be prioritized and will appear as the first item.

If it’s set to “Name” then, childs with names starting with “A” will appear before childs with names starting with “B”.

We then have CellPadding and CellSize;

Those are simple. CellPadding determines how many space there’ll be between each child and CellSize determines the size of the child. The child’s Size and Position are overriden(you can’t change them from their properties until you remove the UIGridLayout).

To end this review, we have the FillDirectionMaxCells;

It’s determining the max cells that can be placed in the “FillDirection”. So, if have the vertical FillDirection and set this to “4” then, only 4 templates can be placed vertically, the next one will be placed horizontally.

END

Thank you for reading :smile: Hope you’re gonna use it better the next time.

6 Likes

Really helpful! Thank you, the API sometimes is a bit hard to understand.

1 Like

UIGridLayout.AbsoluteContentSize (a Vector2) is a phenomenally useful property for all scripters out there, can be great for extending a ScrollingFrame’s CanvasSize to compensate for all the content (ie. a pets list).

3 Likes

Can’t be changed through properties though. I was covering the main ones that can be changed directly from propreties^^. But thank you for the explanation :smiley:

1 Like

I used this script in a previous game, and It does work, but at a certain point, it just starts look weird and just the scale/offset between frames start getting bigger. Anyway this is a script for anyone that needs this in there game, just play around with the frames sizes, UIGridLayout, etc. Until you get it the way you want it.

local UIGridLayout = [Locate the UIGridLayout]
local ScrollingFrame = [Locate your scroll frame]

UIGridLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
     ScrollingFrame.CanvasSize = UDim2.new(0, 0, 0, UIGridLayout.AbsoluteContentSize.Y)
end)