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

How to increase the CanvasSize as more objects are added to a ScrollingFrame?

Asked by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

Hey all! I'm a bit stumbled on how to increase the CanvasSize of a ScrollingFrame, as more objects are added to it. The trick for me, is that the TextButtons within it, use Y Offset, instead of Scale (For both position and size). My original plan was to first set out a template, of how many it would take, until 1 can't be fully seen. Then, add up all of their sizes, then put that as the CanvasSize. However, that didn't work, since the Scrollbar has not yet shown. Any ideas? Each TextButton size is 30 Y offset, and 31 Y offset apart from each other. Any tips?

2 answers

Log in to vote
1
Answered by 9 years ago

Take the last TextButtons Position.Y.Offset and add it's Size.Y.Offset, then set this as the CanvasSize.

0
That does work, however it would keep scrolling until the last button is at the top. How would I make it, so it stops when the last button fully shows at the bottom? Shawnyg 4330 — 9y
Ad
Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

So more guis will be added to it in-game? In that case, you could just use the ChildAdded event. When a new gui is added, increase the size accordingly.

script.Parent.ChildAdded:connect(function(child)
    --Increase CanvasSize based on size of child
end)

I've never actually worked with scrolling frames, but this makes sense to me.

Answer this question