1
Q:

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!");
}
14

New to Communities?

Join the community