Do I need to uninstall the listeners for UnityEvent?

Good afternoon. If I do Destroy(/DestroyImmediate) GameObject-but, do I have to unsubscribe all listeners in MonoBehavoiur's of instances UnityEvent? Or the engine (Unity) he deletes subscribers and the object is marked for garbage collection? The behavior of the cache is not considered.
June 8th 19 at 16:35
1 answer
June 8th 19 at 16:37
If the event source is deleted, why something to do with the subscribers? Subscribers will be removed only if the event source is their parent in the hierarchy. If subscribers don't keep a reference to the object, then do nothing. On the other hand, if you deleted a subscriber not unsubscribing, Yes, the event source will link to the victim object, and then there will be memory leak. In this case the subscriber before his death to unsubscribe, but UnityEvent implemented in such a way that he is dead does not cause a subscription, so decide for yourself if the lifetime of objects varies greatly, then unsubscribe.

Find more questions by tags C#Development of gamesUnity Game Engine