Hello, I’m trying to make my scrolling frame autoadjust to the objects in it. Which I did but theres one problem. It squishes the Ui like A LOT.
.
The scaling uses Scale and not Offset. Not sure if that will have a difference. This is my auto adjust script:
local MyCanvas = script.Parent
local function UpdateCanvasSize(Canvas, Constraint)
Canvas.CanvasSize = UDim2.new(0, Constraint.AbsoluteContentSize.X, 0, Constraint.AbsoluteContentSize.Y)
end
MyCanvas.ChildAdded:Connect(function()
UpdateCanvasSize(MyCanvas, MyCanvas.UIListLayout)
end)
MyCanvas.ChildRemoved:Connect(function()
UpdateCanvasSize(MyCanvas, MyCanvas.UiListLayout)
end)
If you have any questions then say below!
1 Like
dinat13
(BerVrem)
November 6, 2021, 10:30pm
2
A script is not needed to update the canvas size, there’s a property for this and it worked pretty well when i used it
I’m using a listlayout. I don’t see it anywhere.
dinat13
(BerVrem)
November 6, 2021, 10:32pm
4
It’s not in the ListLayout but in the ScrollingFrame
1 Like
Didn’t work. I clicked on none and it doesn’t auto adjust
dinat13
(BerVrem)
November 6, 2021, 10:37pm
6
I think you should click on XY
Ok this works great now. But my UI uses Scale. And it still stretchs out
1 Like
dinat13
(BerVrem)
November 6, 2021, 10:40pm
8
can you take a picture please?
Still small
becomes normal after a few are there.
becomes even more stretched when theres a lot of them
1 Like
dinat13
(BerVrem)
November 6, 2021, 10:49pm
10
I think it’s due to the ListLayout but honestly i don’t know what to do
1 Like
dinat13
(BerVrem)
November 6, 2021, 11:04pm
11
So i tried something
local MyCanvas = script.Parent
local function UpdateCanvasSize(Canvas, Constraint)
Canvas.CanvasSize = UDim2.new(Constraint.Size.X.Scale, 0, Canvas.CanvasSize.Y.Scale + Constraint.Size.Y.Scale, 0)
end
MyCanvas.ChildAdded:Connect(function(child)
UpdateCanvasSize(MyCanvas, child)
end)
MyCanvas.ChildRemoved:Connect(function(child)
UpdateCanvasSize(MyCanvas, child)
end)
but it didn’t work, so sorry but i don’t know what to do!
1 Like
Wait… You can can scale of that?
dinat13
(BerVrem)
November 6, 2021, 11:09pm
13
Yes you can set the scale of a Canvas but the last time i used a scrolling frame it didn’t work with scale so i just worked with offset and scale at the same time
PostVivic
(Vivic)
November 6, 2021, 11:10pm
14
Whenever you set the auto canvas size to y and the frame’s y as scale something interesting happens.
The thing tries to scale the canvas up but that means that the scale of the frame gets affected as well…
To fix your issue however, go to the frame inside of the scrolling frame (the one that’s squished) and set its scaling mode to RelativeXX
This ignores the y scale of the canvas and scales it based off of the x size (which hurray is exactly what you need )
edit: (bonus it also locks the aspect ratio so no weird stretched images)
3 Likes
THANK YOU SO MUCH! With what you said It made the thing not auto change. All I had to do was make the frame(that was being squished) slightly bigger. It also doesn’t change when I add stuff to it! THANK YOU! @PostVivic and @dinat13 !
Edit: this is how it looks. It’s not squished now!
2 Likes