Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Wrong button highlighted in Grid Layout Group

Discussion in 'UGUI & TextMesh Pro' started by pstudio, Jan 12, 2020.

  1. pstudio

    pstudio

    Joined:
    Apr 20, 2014
    Posts:
    12
    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.



    https://imgur.com/1t4NupX

    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?
     
  2. LoneSurvivor82

    LoneSurvivor82

    Joined:
    Aug 17, 2019
    Posts:
    41
    I have a similar problem, could you solve yours?
     
  3. pstudio

    pstudio

    Joined:
    Apr 20, 2014
    Posts:
    12
    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.
     
  4. viseztrance

    viseztrance

    Joined:
    Feb 7, 2019
    Posts:
    15
    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.
     
    lghfoo likes this.