Quantcast
Channel: UGUI & TextMesh Pro
Viewing all articles
Browse latest Browse all 23263

Remove only 1 Button click Event which have optional parameter

$
0
0
So if we want to remove 1 listener event without parameter, then we can use it
UnityEngine.Events.UnityAction action = () => { myMethod(); myOtherMethod(); };

myButton.Getcomponent<Button>().onClick.AddListener(action);

myButton.Getcomponent().onClick.RemoveListener(action);

But the problem I can't do that with an even which have parameter. Something like
tempGO.GetComponent<Button>().onClick.AddListener(()=>onCollectItemClick(tempGO));

I can't save a point to this delegate because...

Remove only 1 Button click Event which have optional parameter

Viewing all articles
Browse latest Browse all 23263

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>