using UnityEngine; using System.Collections; using UnityEngine.UI; public class DemoController : MonoBehaviour { public GameObject btn; //public Button btn; private void Start() { btn.gameObject.GetComponent<Button>().onClick.AddListener(this.BtnOnClick); //btn.onClick.AddListener(this.BtnOnClick); } void BtnOnClick() { Debug.Log("我被点击了!"); } }