- Home /
Remove Listener from Button via Script
I added a Listener even to my buttons using this:
Button b = GetComponent(); b.onClick.AddListener(() => {GoTo(MenuState.Categories);});
I want to be able to change the function of the button later. If I add another Listener I'll just have 2 calls instead of 1. So how can I clear the Listener list on the button?
Comment
Best Answer
Answer by fafase · Mar 19, 2015 at 07:40 PM
Either :
http://docs.unity3d.com/500/Documentation/ScriptReference/Events.UnityEvent.RemoveListener.html
for one or:
for all.