Wrong button highlighted in Grid Layout Group

Hi,

I’m working on a quick project and need to create x amount of buttons at runtime layout in a grid.
It would seem the Grid Layout Component is the perfect candidate for the job. However I’m having a slight issue. The buttons are perfectly layout in a grid as desired, but when I try and click on a button the wrong button is selected.



Imgur

If you look at the image you can see that the wrong button is highlighted compared to where the mouse cursor is. I suspect there is some setting I need to set in one of my components or similar, but I haven’t been able to figure out which. I’ve messed around with plenty of different layout components and their settings, but nothing has changed this behaviour.

Anyone know how to resolve this issue?

I have a similar problem, could you solve yours?

I did solve it, but I can’t remember what was the exact solution. I believe it was resolved by messing about with the different layout components and their options.

I had a quick look at the project and this is the setup.

On Panel there’s a Content Size Fitter set to Min Size and a Vertical Layout Group with Child Force Expand set.
On the Grid itself there’s just the Grid Layout Component and that works for me.

Hope that might help you.

I had the same issue, though my buttons had a gameobject child with a text mesh pro component attached to them.

Disabling raycast on the tmpro text (under “extra settings”) fixed the issue for me.

4 Likes

This solved the problem for me! Thank you!