Help with UIGridLayout

Ok, so I have buttons in a frame with a UIGridLayout inside of it.
I want to change a button’s size when it gets hovered, but the size is restrained by the UIGridLayout.
Is there a way I can only change that button’s size without changing the size of the rest of the buttons?

Thank you for any help!

3 Likes

but the size is restrained by the UIListLayout.

sounds like you’re using UIGridLayout not UIListLayout

3 Likes

As far as I’m aware, UIListLayout only controls the spacing/padding between the buttons (What restricts the size is the UIGridLayout).

Normally with these things you could do a simple MouseEnter and MouseLeave:Connect() where whenever it enters, you can have it expand it’s size and then when it leaves, bring back to normal.

1 Like

oh yeah my bad. I meant UIGridLayout. I’ll fix that now.

In this case, right now UIGridLayout doesn’t neccesarily have that ability in its properties to where hovering can increase one button’s size, may require extensive scripting. May I ask if you can send a picture of how your current UI looks like atm?

simple fix would be to just use UIListLayout instead

This is unless the current UI design requires the usage of a grid design. If the current design caters to a list then yeah, just pretty much what I mentioned above to help achieve the effect:Help with UIListLayout - #3 by w4570

1 Like

I can’t use UIListLayout for this. It needs to be a grid.

then you could try using frames to hold the buttons i could show what i mean in a second

I think it does have that ability, I have seen games that almost definitely use grid layouts and they have hover effects where the buttons change sizes.

That’s inefficent though, and I’d also have to change scripts for that to work.

Just want to establish that a part of the UIGridLayout properties is “CellSize” which basically already establishes what size each cell grid should be. If ever it’s manipulated, it will apply for all cell as well and not just one.

BUT, If I were to think of a workaround to this, You could possibly have something where each button of the Grid is stored in a frame (So the UIGridLayout is setting the grid size for every frame and in each frame stores a button that maybe has a size of lets say 0.8, 0, 0.8,0). From there just apply the same logic as the mouse enter and leave.

That is possibly the best I can come up with to work around the current nature of the UIGridLayout.

So yeah you can have a for loop store all the elements. If v.TextButton is a Text Button then, MouseEnter:Connect() leads to TweenSize to 0.99. MouseLeave:Connect() leads to TweenSize to 0.85

[Just an example]

That would work, but then I would have to rewrite all scripts that use buttons stored there. because they are inside a frame now.

i’m assuming you wouldn’t have to rewrite much
only the location of the buttons (not sure how your script works)

I figured out a solution using UISizeConstraints. I didn’t even know these existed, since I was just messing around with constraints until I found this out. I basically just set the MaxSize property of the size constraint to be smaller when the mouse enters the button, and larger when the mouse leaves.

Thanks so much for your help everyone!

1 Like

probably should’ve asked how you wanted to size your buttons earlier

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