public void OnClick()
{ var button = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject; print(button.name); } Hang the script on an object, and then set this function on the button component to set OnClick(). You can see the print To the name of the button