Hi! this is a pretty straightfroward question
I use events on various places of my AI scripts, and i have read that event subcription and unsubcription must be done in OnEnable and OnDisable respectively, wich works well enough but since im using pooling for my AI’s OnEnable and OnDisable will be called more than 1 time, and sometimes, 10 enemies will get enabled at the same time, therefore making 10 calls to OnEnable.
All this make me ask, how heavy really is subscribing to events? i need to keep this into account, since my AI will spawn from my pool, and will get disable and enabled multiple times, and i was thinking, maybe instead of OnEnable and OnDisable i should use Awake and OnDestroy, since these will get called only once, so no matter how many times my Ai’s get enabled and disabled, the event subscription will get called only once, but then comes out the question of memory leaks, what do you think?
In summary :
-Are OnEnable and OnDisable really the best place to subscribe and unsubscribe?
-Would Awake and OnDestroy also work?
-How performance and CG heavy is event subscription and unsubcription?