Event Notifiers - edcasillas/unity-common-utils GitHub Wiki
Event notifiers are components that catch MonoBehaviour events so you can redirect them to another object and act accordingly.
Common use cases for these components include:
- Hiding game object when another game object is hidden, but the first one is not a child of the second.
- Delay the activation of a game object until another game object is enabled.
- Execute a script in game object A when game object B collides with any other game object.
There are two variants of these event notifiers:
UnityEventsNotifier
is able to notify about theAwake
,Start
,OnEnable
,OnDisable
,OnBecameVisible
andOnBecameInvisible
events.- TriggerNotifier is able to notify about the
OnTriggerEnter
andOnTriggerExit
events.
Listeners to these events can be added at design-time through the Inspector, or at runtime calling the Subscribe[event_name]
method of the event notifier component. Likewise, listeners can be removed by calling Unsubscribe[event_name]
.