How do I have the UIGridLayout keep all icons square in a scrolling frame?

Hello, I am attempting to make an inventory system, and have encountered an issue. I am using a scrolling frame (AutoCanvasSize enabled) and a UIGridLayout. I wish to keep the icons that are part of the UIGridLayout to remain squares

However, I have discovered that when I try to do this, as the scrolling layout gets bigger from more icons, all the icons stretch down, with many being off of the frame (way off down the bottom).

Anyone know what I would be doing wrong / need to change to allow this to work?

Thank you!

2 Likes

So i remember running into this problem and it was a simple fix for me. Turns out i forgot to check the “Anchor Position” box which caused the UI to be messed up. So if you haven’t already, try checking if your UI is anchored or not, a lot of developers forget to do it

Where is this Anchor Position box? I can only find the Anchor Point, which uses 2 int values?

I searched up what you said online and found the uiaspectconstraint…

It seems easier than my counter measure, which was writing a code to do it automatically (that is more or less correct)

local function Resize()
	script.Parent.CellSize = UDim2.new(0.2,0,0,script.Parent.Parent.Frame.AbsoluteSize.X)
	script.Parent.CellPadding = UDim2.new(0.05,0,(script.Parent.AbsoluteCellCount.Y*0.05)+0.05,0)
	script.Parent.Parent.CanvasSize = UDim2.new(1,0,(script.Parent.AbsoluteCellCount.Y*0.25)+0.25,0)
end


script.Parent.Parent:GetPropertyChangedSignal("Visible"):Connect(Resize)

Thank you for your help though!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.