Create a script like button on click event in unity code example
Example: unity assign button onclick
public Button yourButton;
void Start ()
{
Button btn = yourButton.GetComponent<Button>(); //Grabs the button component
btn.onClick.AddListener(TaskOnClick); //Adds a listner on the button
}
void TaskOnClick()
{
Debug.Log ("You have clicked the button!");
}