Get name of button in c#

just started with UI 4.6 and try to find out how I can get the name of a selected button object into a script.thanks in advance for help

say you have a UI Buttonand and on the OnClick Listener you added a gameobject with a script that is executed when button is pressed. this will get the gameobject button name.

string name =;

The beautifully concise answer by vfxjex works well for me

string name =;

you just need to add this at the top of your codeā€¦

using UnityEngine.EventSystems;