Hi there,
We used public events in the third person combat course and did a couple of things differently there. I’m just wondering whether these changes are important or not for the sake of my understanding.
The first is that when we’ve used actions in the past we would usually invoke it using code similar to this:
onConversationUpdated?.Invoke();
This carries out a null check to make sure there is a subscriber to the event and then triggers it if so. Sam just called it like a method in this video, does that perform the same job and bypass any null errors? It seems marginally easier to do it Sam’s way is all, so I’m wondering if there are any downsides?
The second is that when we’ve subscribed to an event in the past, it’s always been made clear that we need to unsubscribe from that same event so as to prevent memory leaks. Is there a reason that we wouldn’t unsubscribe from this event in OnDisable() or OnDestroy()?
Thanks in advance!
Josh