unity UGUI 点击button获取button的名字

public void OnClick()
{
var button = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject;
print(button.name);
}
将脚本挂在一个物体上,然后button组件设置OnClick()上设置这个函数,打印可以看到button的名字

猜你喜欢

转载自blog.csdn.net/qq_40544338/article/details/111270759