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);
}
网友评论