Registering to events from code
4_ScriptableEvent
Last updated
4_ScriptableEvent
Last updated
Alternatively to using the Event Listeners, you can directly subscribe to an event by code. If you select the Heal vignette, you can see an example.
UICanvas/Heal Vignette
Let's inspect the code of the HealVignette.cs. Registering to an event is straightforward, simply subscribe your method to the OnRaised action of the event. Your method will then be called when the event is raised. In this case, the method OnPlayerHealed will be called and activate the fade out.
Note : don’t forget to unsubscribe from the event OnDestroy() or OnDisable() for safety.