Tell me, please, can I get the name of a UI-button in Unity from the method which is hung on my button (OnClick())? How?
CodePudding user response:
1 .Add Event Trigger in Inspector to your Button
2. click Add New Event Type and add a pointer click event.
3. drag your gameobject containing this script in the script area.
4. assign the below function in the function area.
5. assign the button in the parameter area.
-------This is code---------
public void OnClicked(Button button)
{enter code here
print(button.name);
}