Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would I script an adaptable scroll frame?

Asked by 5 years ago

So I plan on having a scroll frame that inside has multiple buttons laid out using UIGrid layout or UIList layout, and every time you collect an item it adds to the inventory. But eventually the entire frame would be taking up but the scrollbar has met it's maximum scroll distance, how would players be able to reach to the bottom?

I have noticed that there is a property called CanvasSize, but how would I need to change the size of it so that any amount of items can be included inside, potentially a HUGE amount. What kind of fancy maths would I need to do?

0
make a search bar using string.match() User#23365 30 — 5y
0
I mean, you could make a UI that doesn't work off scrolling but off pressing a button to go to the next page of items... Like a little arrow key at the bottom of the UI that just tweens the next frame with the list of buttons. KingLoneCat 2642 — 5y

1 answer

Log in to vote
1
Answered by
ee0w 458 Moderation Voter
5 years ago
Edited 5 years ago

Fairly easy, actually. A UIListLayout has an AbsoluteContentSize that you can use for your canvas size. Consider the following:

UIListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
    local size = UIListLayout.AbsoluteContentSize
    ScrollingFrame.CanvasSize = UDim2.new(0,size.X,0,size.Y)
end)

This will update the CanvasSize every time the content changes.

If I helped, be sure to upvote/accept!

0
Lovely stuff! Thank you! Marmalados 193 — 5y
Ad

Answer this question