-
Notifications
You must be signed in to change notification settings - Fork 0
EventSystem ‐ Classic
The event system uses the argument type to differentiate between each event, calling every listener for that specific type.
Subscribe/Unsubscribe listeners and fires events.
All managers prevent duplication when subscribing listeners and errors when unsubscribing them.
⚠ But there is no way to check for dead listeners, so always unsubscribe during
OnDestroy()and/orOnDisable()
The core component for every manager, can be used as a standalone object to register listeners and fire events.
Used as a component in a GameObject, it acts as a middle-agent that can fire the event locally to listeners that only registered with it or globally, by calling the Scriptable Object manager.
The global manager, can be referenced directly or by component managers.
The main inteface used to create custom events.
For better performance and good practices, create events using read-only Structs. Only use Classes when really necessary, as they can create a lot of work for the GC system, specially in events called in hot paths.
As another good practice, prefer the use of IEventArgsWithSender to always send a reference of the sender to the listener, it's specially useful for debugging purposes or creating dynamic connections between objects.