AnimancerState.

Events(AnimancerEvent.Sequence) Method

Summary

If the `events` are null, this method assigns a new Animancer.AnimancerEvent.Sequence and returns true to indicate that the caller should now initialize their event callbacks. Otherwise, this method simply assigns the provided `events` to this state and returns false.
Assembly
Animancer.dll
Namespace
Animancer
Containing Type
AnimancerState

Syntax

public bool Events(ref AnimancerEvent.Sequence events)

Remarks

If this state already had events, the new Animancer.AnimancerEvent.Sequence will be a copy of those events for the caller to own.

This method allows multiple callers to safely take turns using the same state as long as they each call this method to assign their own events.

Also calls Animancer.AnimancerState.AssertOwnership(System.Object).

Documentation: Animancer Events

Example:
public static readonly StringReference EventName = "Event Name";

private AnimancerEvent.Sequence _Events;// Don't new() this.

...

AnimancerState state = animancerComponent.Play(animation);

// The first time this is called it will assign a new event sequence
// to the _Events and return true so you can initialize it.

// After that, it will just re-assign the _Events to the state.
// and return false so you don't need to re-initialize the events.

if (state.Events(ref _Events))
{
    _Events.SetCallback(EventName, OnAnimationEvent);
    _Events.OnEnd = OnAnimationEnded;
}

Parameters

Name Type Description
events AnimancerEvent.Sequence

Return Value

Type Description
bool