Unity Events Usage

Unity API on Unity Events
Unity Doc on Unity Events

Let's first go through the available unity events. The names already give a decent idea what the different unity events are for, but we'll go through them one by one next.

Unity Event Example 1

  • UnityEvents_Collision: Events are invoked from a collision enter or exit between two objects. You can use the tag-dropdown from options to limit by tags. Note that at least one object needs a rigid body-component for the collision to register.

  • UnityEvents_Input_Global: Events are invoked by a custom input action. This refers to the input actions found in InputSet-scriptable object in 00ViD/Resources/Core/Input/InputSet. Find more info on custom actions via InputSet here(link soon).

  • UnityEvents_ParticleCollision: Events are invoked by a particle collision. This requires particle system to have collisions feature enabled and from it the "Send collision messages"-boolean enabled. You can use the tag-dropdown from options to limit by tags.

  • UnityEvents_Scenes: Events are invoked by scene messages: OnSceneLoaded; OnSceneUnloaded; ActiveSceneChanged. Has option to require a current scene or next scene to invoke. This unity event requires Game Manager to be set up with correct scene file names.

  • UnityEvents_ScenesString: Same as above, but this uses a string parameter argument which can be passed to the function that is called.

  • UnityEvents_Spawn: Events are invoked by spawn messages: OnSpawn; OnDespawn. This component has to be in the same object that does the spawning. Check section for Spawning for more info(link soon).

  • UnityEvents_Trigger: Events are invoked from a trigger collision enter or exit between two objects. You can use the tag-dropdown from options to limit by tags. Note that at least one object needs a rigid body-component for the trigger collision to register!

  • UnityEvents_TriggerGameObject: Same as above, but this uses a GameObject parameter argument which can be passed to the function that is called.

  • UnityEvents_UnityMessages: Events are invoked by unity messages: Awake; Start; OnEnable; OnDisable; OnDestroy. Very useful for generic events. Like all our events, this can also be used without selecting any invocation triggers and invoked manually from somewhere else.

  • UnityEvents_VDEvent: Events are invoked by custom VDEvents. This refers to the scriptable objects found in 00ViD/Resources/Core/Events/VDEvents. Find more info on VDEvents here(link soon).

  • UnityEvents_VDEventRaiseOnTrigger: Custom event for invoking VDEvents. Find more info on VDEvents here(link soon).

  • UnityEvents_VDEventRaiseWithArgs: Custom event for invoking VDEvents with parameter arguments. Find more info on VDEvents here(link soon).

When to use unity events and when not, and what other options are there: