Search Unity

Unity UI GridLayoutGroup mousePosition over which element?

Discussion in 'UGUI & TextMesh Pro' started by jGate99, Oct 14, 2019.

  1. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Hi there,

    I have a GridlayoutGroup with 10x10 = 100 elements, and i want to know on which element my mouse clicked.

    One bad way to do is by turning those 100 elements as buttons, which i want to avoid.

    Right way to do is, get mouse position, then convert that position to GridLayoutGroup's Child's anchoredPosition's equalvant. and round that value to that cell.
    Problem is i know the theory but not the math and how do i convert these.

    So here for assistance from community.
    Thanks