The title says most of it, I need to have my own version of Automatic Canvas Size for a scrolling gui, as the listings of a gui are added by a script, not hardcoded.
If you’re using a UIListLayout, automatic canvas size should work here (if it’s set to XY or just Y), otherwise, I would add up all the frame’s Y scale/offset (depending on which one you’re using) and add the spacing (Padding). Not sure if this is what you’re looking for, but hopefully it will help with your issue
I’m using autocanvas XY, I could use just Y but I’m just using XY for whatever reason. The issue is that automatic canvas size isnt scaling automatically when new guis are added to the scrollingframe.
You need to add the size and the padding to the script and it should work but you should try manually adjusting the canvas size first to make sure that the system would work.
I’d like to bump this with some more information, since I’m still encountering issues.
The equation shown in the above post doesnt work, it, for whatever reason, gets offset over time, & makes the canvas way larger than it should be. AutomaticCanvasSize should be doing this for me but for whatever reason its not automatically expanding when I add new items to it.
These are all of the properties relating to the issue:
Every gui in this game are sized using scale, the items are added after the game launches using the following code:
local Player = game.Players.LocalPlayer
local AttributionsModule = require(game.ReplicatedStorage:WaitForChild("Resources"):WaitForChild("Data"):WaitForChild("Attributions"))
local AttributionsTemplate = Player:WaitForChild("PlayerGui"):WaitForChild("MainHud"):WaitForChild("AttributionsFrame"):WaitForChild("AttributionsFrame")
local OriginalTemplate = AttributionsTemplate:WaitForChild("Attribution")
local AttributionSpacing = (OriginalTemplate.Size.Y.Scale + OriginalTemplate.Position.Y.Scale)
local Iteration = 0
for Index,Data in pairs(AttributionsModule.Items) do
local AttributionClone = OriginalTemplate:Clone()
AttributionClone.Parent = AttributionsTemplate
AttributionClone.Position = UDim2.new(.02,0,(AttributionSpacing * Iteration),0)
AttributionClone.Creator_Name_Label.Text = Data.Creator_Name
AttributionClone.Platform_Name_Label.Text = ("of "..Data.Creator_Platform)
AttributionClone.Attribution_Description.Text = Data.Contribution_Description
AttributionClone.Link_Text.Text = Data.Link
Iteration += 1
end
AttributionsTemplate.CanvasSize = UDim2.new(0,0,(AttributionSpacing * (Iteration - 1)),0) --This is the line that is messing up, the sizing isnt correct, & it makes a bunch of extra space at the bottom.
OriginalTemplate.Parent = nil
The thing that confuses me is that while the size of the canvas is way too large, all of the items inside the ScrollingFrame are using the same equation, just without Iteration - 1.
I just remembered I made a custom chat system a while back and had the same exact issue, except it cut off from the bottom instead of giving extra space.
Though the way I fixed it was using AutomaticCanvasSize. Is there anything else inside of the AttributionsFrame that is GUI related?