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.
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.
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.