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

UnityEvent malfunction

$
0
0
When we assign method from script A (MonoBehaviour), to script's B event which inherits from UnityEvent by AddListener method, it (A method) receives callbacks. When we disable component A (script A) it still receives callbacks.

This behaviour is unwanted and it force us, to write everywhere the same pattern. Add listeners in OnEnable and remove them in OnDisable methods. I thought unity's events in comparision with .NET ones at least gives us this "syntactic sugar".

Viewing all articles
Browse latest Browse all 23263

Trending Articles



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