Unity UGUI click the button to get the name of the button

 

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



Guess you like

Origin blog.csdn.net/qq_40544338/article/details/111270759