If you use UIListLayout
frequently in your games, you’ve been looking for a method to fix it.
I’ve been thinking of some way to run it automatically
and arrived in a simple mathematical form and very practical and Functional! This code will help you a lot when you are creating a UI that uses Clone ()
as for example a “Top Global”.
How I made this code:
Basically to fix the UIListLayout
I multiplied the default size (Y.Scale
) (before modifying according to the ScrollingFrame) by How Many Frames will be inside the ScrollingFrame, and then changed the value of Scrolling.Cavansize to the Result.
then I created a Loop to adjust all the children of ScrillingFrame, to adjust their size I used the standard size (Y.Scale
) of the Frame (Clone()
) divided by the Size of CanvanSize (the result above), thus the size of each child within the ScrollingFrame it had adapted to the size of the platform.
Note: For this function you need to set the height in Scale.
Fix Code:
for i = 1,10 do
local Clone = script.Frame:Clone()
Clone.Name = "Number: "..i
Clone.Parent = ScrollingFrame
------Fix------
local CanvaValue = Clone.Size.Y.Scale*(i)
ScrollingFrame.CanvasSize = UDim2.new(0,0,CanvaValue,0)
for i,v in pairs(ScrollingFrame:GetChildren()) do
if v.Name ~= "UIListLayout" then
v.Size = UDim2.new(1,0,Clone.Size.Y.Scale/CanvaValue,0)
end
end
------end------
end
I hope I helped you.
If this topic was useful do not forget to command and leave your finger up.