Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unity, getting the name of the UI button

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?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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);
}

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading