Scrolling frames with scale based content? (UIGridLayout)

I’ve never used a UIGridLayout object (or any of those UI constraint objects except for aspect ratio)
My scrolling frame is scale based, and it’s contents are as well.

My scrolling frame is ({.35,-8},{.7,-8})

My CellSize is ({0.5, -6}, {0.3, 0})
and my CellPadding is {0,8,0,8}

this code is slightly modified from what I found on the wiki for UIGridLayout objects, but that article is designed for ScrollingFrames and Contents that are based on Offset, rather than scale.

local function onContentSizeChanged()
			local absoluteSize = Menu.Customization.Selector.ScrollUtility.UIGridLayout.AbsoluteContentSize
	Menu.Customization.Selector.ScrollUtility.CanvasSize = UDim2.new(0, absoluteSize.X, 0, absoluteSize.Y)
	print(absoluteSize.X,absoluteSize.Y)
end
 
Menu.Customization.Selector.ScrollUtility.UIGridLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(onContentSizeChanged)
		
spawn(function()
	for i=1, 20 do
		local util = Menu.Customization.Selector.ScrollUtility.Content:Clone()
		util.Parent = Menu.Customization.Selector.ScrollUtility
		wait(1)
	end
end)

The loop is for testing purposes; Here is the (strange, yet expected) outcome

https://gyazo.com/3524c1439bbac7e6d623f6727ca5398c

Any suggestions? Or am I going to have to go some hardcoded math route? I’m really trying to learn to use more of the UI objects that roblox provides.

Went with math route. For anyone interested;

local function onContentSizeChanged()
			local absoluteSize = Menu.Customization.Selector.ScrollUtility.UIGridLayout.AbsoluteContentSize
			local NewSize = .3 * Menu.Customization.Selector.ScrollUtility.AbsoluteSize.Y
			Menu.Customization.Selector.ScrollUtility.UIGridLayout.CellSize = UDim2.new(0.5,-6, 0, NewSize)
			Menu.Customization.Selector.ScrollUtility.CanvasSize = UDim2.new(0, absoluteSize.X, 0, absoluteSize.Y)
			print(absoluteSize.X,absoluteSize.Y)
		end
 
		Menu.Customization.Selector.ScrollUtility.UIGridLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(onContentSizeChanged)
		onContentSizeChanged()
1 Like