Search Unity

How to get the index of the button from a list of buttons when a button is clicked from the list

Discussion in 'UI Toolkit' started by Tanay365, Oct 10, 2021.

  1. Tanay365

    Tanay365

    Joined:
    Sep 25, 2021
    Posts:
    1
    I want to get the index of the button clicked from a list of buttons when a button is clicked from the list of buttons!

    If I have button1, button2, and button3 in the list, then after adding the click listener for the buttons in code, I want to detect which button is clicked when I press any of those three buttons!
     
  2. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    698
    Can you share the code you're using so we know how you're assigning click listeners? The answer may vary :)