Hi. I am making quite a lot use of C# events. I know I have to make sure to unsubscribe the events if I dispose/destroy objects. Therefore I am usually subscribing and adding an unsubscribe-action to a list.
I invoke those unsubscribe-actions in the OnDestroy-method of MonoBehaviours.
My problem is, that OnDestroy is not immediately called after Destroy(gameObject). So events will still fire up to that point.
Is there any other method/callback I could use to immediately do some action after Destroy is called on an object?
I don’t like to manually call a method, because I might forget to call it. Therefore I thought the OnDestroy-method is a good place to clean things up.
How do you guys handle events and the problems that come with it?