Take a look at the code from the manual.
using UnityEngine; using UnityEngine.UI; using System.Collections; public class ClickExample : MonoBehaviour { public Button yourButton; // Put your button in here void Start () { Button btn = yourButton.GetComponent<Button>(); btn.onClick.AddListener(TaskOnClick); //When the button gets clicked/pressed it will call TaskOnClick() function below } void TaskOnClick() { Debug.Log ("You have clicked the button!"); } } I hope this helps. I've struggled with this same topic a while ago and this helps