So my scrip will put ImageLabels inside the scrollingframe, but i dont have idea how auto scale the CellSize, so that keep happening
(As you can see the canvas size was not the right size)
I tried to make the code auto scale the Canvas Size (only y), and make the system auto scale the CellSize, so that the items are the right size.
Code:
local Gui = script.Parent.Parent
local ScrollFrame = Gui.storage.scrollFrame
local SlotAmount = 80
local Slot = Gui.storage.PreModels.slot
local UIGridLayout = ScrollFrame.UIGridLayout
local PADDING = Vector2.new(0.2, 0.2)
local SIZE = Vector2.new(0.3, 0.1)
-- Convert desired values to offset
for i = 1, SlotAmount do
local Clone = Slot:Clone()
Clone.Name = "slot"..i
Clone.Visible = true
Clone.Parent = ScrollFrame
end
local Cs = UIGridLayout.AbsoluteContentSize
ScrollFrame.CanvasSize = UDim2.new(0,0,0,Cs.Y)
local AbsoluteSize = UIGridLayout.AbsoluteSize
local NewPadding = PADDING * AbsoluteSize
NewPadding = UDim2.new(0, NewPadding .X, 0, NewPadding .Y)
local NewSize = SIZE * AbsoluteSize
NewSize = UDim2.new(0, NewSize.X, 0, NewSize.Y)
UIGridLayout.CellPadding = NewPadding
UIGridLayout.CellSize = NewSize