UIGridLayout.AbsoluteCellSize

As a Roblox developer, it is currently too hard to get the absolute size of cells in a UIGridLayout without having unnecessary code.

Right now, to get the AbsoluteCellSize for a UIGridLayout you have to do:

function getCellSize()
    for i,v in pairs(frame:GetChildren()) do
        if not v:IsA("UIComponent") then
            return v.AbsoluteSize
        end
    end
end

frame.UIGridLayout.CellSize = UDim2.new(0.2,0,1,0) --To set the absolutesize
wait()
frame.UIGridLayout.CellSize = UDim2.new(0.2,0,getCellSize().X,0)

All that could be cleaned up if this property was made.

frame.UIGridLayout.CellSize = UDim2.new(0.2,0,frame.UIGridLayout.AbsoluteCellSize.X)

1 Like

What is the use case?

For making a UIGridLayout have square cells in a frame that could change size dynamically.

You can parent a UIAspectRatioConstraint to the UIGridLayout to force the cells to be square.