Cinemachine Events
Cinemachine generates events in the following contexts:
- Whenever cameras are activated and deactivated.
- When blends are started and when they finish.
- When there is a camera cut, that is, when the active Cinemachine Camera changes without blending.
Note
Cinemachine also exposes some Unity Events that you can use to send callbacks to Cinemachine objects. For more information about Unity Events, refer to Inspector-configurable custom events.
Cinemachine event flow
When Cinemachine sends an event, it sends it globally via CinemachineCore. Scripts can add listeners to those events and take action based on them. Listeners receive events for all cameras and all brains.
Events are generated in every context that manages blends. This includes the Cinemachine Brain, which handles blends at the highest level, but it also applies to Cinemachine Camera Managers, which themselves manage blends between their child cameras.
Filter Cinemachine events
Sometimes it's desirable to handle events sent for a specific Cinemachine Camera, a specific Cinemachine Camera Manager, or a specific Cinemachine Brain, so that scripts can be notified based on this specific object's activity without having to provide code to filter the events.
Cinemachine provides the following components to execute this filtering logic:
To trap events that relate to activating or deactivating a specific Cinemachine Camera or Cinemachine Camera Manager, add a Cinemachine Camera Events component to it.
To trap events generated by a specific Cinemachine Camera Manager, add a Cinemachine Camera Manager Events component to it.
To trap events generated by a specific Cinemachine Brain, add a Cinemachine Brain Events component to it.