Here’s the hierarchy, and UIPadding that should be applied by logic
All i need is find the way to return the padding without getting rid of automatic size calculations. Well i could use “Magic number” for frame’s size, but that’s not the ideal option…
The Collection’s UIPadding.PaddingRight seems to not be working so I think we are going to try to mimic the PaddingRight by calculating Collection’s Size.X
(Btw, I will use offset because I only see you using offset)
To find that Collection X size, we know what the X size of the elements within:
_Collection.UIPadding.PaddingLeft.Offset + Collection.UIPadding.PaddingRight.Offset
_Collection.UIListLayout.Padding.Offset * 1 (It looks like you use it to space Grid and Info one time only, so I multipled by 1 or you can just remove 1)
_Grid.UIGridLayout.CellPadding.X.Offset * 3 + Grid.UIGridLayout.CellSize.X.Offset * 4 (I multiplied by 4 because I see that you only use 4 boxes in each row and 3 padding between 4 boxes)
Since the calculations above is too messy, we can also just calculate it by using Grid Size and Info Size: Grid.Size.X.Offset + Info.Size.X.Offset Collection.UIListLayout.Padding.Offset Collection.UIGridLayout.PaddingLeft.Offset + Collection.UIGridLayout.PaddingRight.Offset UIStroke.Thickness
Ok, so. I’ve solved the problem in the worst way possible.
It’s “the worst” not because it doesn’t work, but because it’s not the case i really expected.
Ok, fine, screw it.
Now to the point what i’ve done for the solve…
Previously, i didn’t want to write additional scripts that will handle the size, but seems like i have no choice in the end. So right now, i check for elements added/removed and “AbsoluteContentSize” change.
local Scrolling = script.Parent
local UIGridLayout = Scrolling:FindFirstChildOfClass("UIGridLayout")
local UIPadding = Scrolling:FindFirstChildOfClass("UIPadding")
function Update()
Scrolling.Size = UDim2.new(
UDim.new(0,UIGridLayout.AbsoluteContentSize.X) + UIPadding.PaddingRight + UIPadding.PaddingLeft,
UDim.new(1,0)
)
end
Scrolling:GetPropertyChangedSignal("AbsoluteCanvasSize"):Connect(Update)
Scrolling.ChildAdded:Connect(Update)
Scrolling.ChildRemoved:Connect(Update)
Scrolling.AutomaticSize = Enum.AutomaticSize.None