//this is Unity pared with C# using UnityEngine.EventSystems; public class Class : Monobehaviour { //Call this function when the button is pressed public void ButtonClicked() { string name = EventSystem.current.currentSelectedGameObject.name; } }