Unity Button带参数点击事件
2022-06-25 本文已影响0人
114105lijia
void Start()
{
//写法1
gameObject.GetComponent<UnityEngine.UI.Button>().onClick.AddListener(() => Click(text));
//写法2
gameObject.GetComponent<UnityEngine.UI.Button>().onClick.AddListener
(
() =>
{
Click(text);
}
);
}
void Click(string text) {
Debug.Log(text);
}