Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unity button addlistener

//you probably want to remove existing listener before adding a new one
//myButtonGameObject.GetComponent<Button>().onClick.RemoveAllListeners();
myButtonGameObject.GetComponent<Button>().onClick.AddListener(delegate { MyMethodToPass(); });
 
PREVIOUS NEXT
Tagged: #unity #button #addlistener
ADD COMMENT
Topic
Name
7+6 =