//UnityEvent that is triggered when the button is pressed. public Button yourButton; void Start() { btn.onClick.AddListener(TaskOnClick); } void TaskOnClick() { Debug.Log("You have clicked the button!"); }