Index of clicked btton.

I have GameObject and four buttons in it. I want to know index of clicked button.

Then declare a public method (in a script on that GameObject) that takes an int parameter. Hook that up as the event handler for each of the clicked events, and specify whatever index value you like for each one.

(I assume you’ve already gone through the UI tutorials in the Learn section, so you know how to use events.)

2 Likes

But I want do it by script. I mean, script declare which in order is button in hierarchy.

I think it’s the second one you are after. But you need to watch them in order.

1 Like

Thank you @Kiwasi . This solved my problem.

1 Like