Problem I am having with the GridLayout is that it requires a size. I have a UIAspectRatioConstraint inside the items, and that’s what keeps the items to be square. But with GridLayout you can’t do that (unless I use Offset, but that’s a big no!)
I don’t believe there is any functionality to do this without wrapping your buttons in Frames. It’ll clutter up your explorer window a bit, but if you put the buttons inside invisible frames you should be able to do this.
On another note:
I don’t understand why people say this, Offset is hugely useful, if you use it correctly. The reason most people advocate for Scale is so that your UI works across devices, but you can definitely still use Offset where appropriate (especially useful when working with the absolute sizes of UI objects in scripts, for example)
Reason to not use Offset is because it’s near impossible to make things sized correctly. Something that’s really big on mobile will look miniscule on a 80-90" TV screen for console.
Yea ik, but every game I make has UI scaled from iphone 4 - console. A lot of games lose tons of potential play sessions and robux spent because they don’t fully work on mobile/tablet and those 2 devices are probably the biggest earners in most games. If UI ain’t scaled for those, then that’s basically 2 of the biggest markets wiped out
Yep, there is a way to use the UIAspectRatioConstraint with the UIGridLayout, just parent your UIAspectRatioConstraint to your UIGridLayout and it will apply itself to all GuiObjects the UIGridLayout is managing.
Make sure your UIGridLayout is using scale instead of offset so that the icons will fit in your frame correctly and scale to screen size. I suggest only using offset for things like border pixels or small underlines.
If you’re going with 3 columns per row of icons/gamepasses, the process to make your UI would be something like the following:
Step 1) Determine size.
Leaving 10% for room, your size would be 30% ((1-.1)/3 = 0.3).
Step 2) Make sure your UIGridLayout has its FillDirectionMaxCells set to 3 (or your columns per row). I suggest centering your UIGridLayout horizontally but not vertically. Play with how you’d like it centered.
Step 3) Mess with spacing as you’d like, or calculate it based on the room you left and the amount of rows you’d like. To calculate, divide your spacing by your number of columns per row plus one. We add one to accommodate the edges. In our example of 3 columns per row, there are two spaces in between the columns and two spaces between the exterior columns and the edges of your frame. In total you’ll have 4 spaces. The centering of your columns can also be impacted by your UIAspectRatio constraint being set to FitWithinMaxSize.
A mathematical example of calculating the padding for your UIGridLayout:
Spacing = .1 (10%)
Padding = 0.025 (.1/4 = 0.025, aka 2.5%)
Therefore, your X padding would be 0.025. This would center your gamepasses or icons perfectly (as long as they have vertical space).