AnimancerState.

Events(Object, AnimancerEvent.Sequence) Method

Summary

If the Animancer.AnimancerState.OwnedEvents haven't been initialized yet, this method gets them and returns true.
Assembly
Animancer.dll
Namespace
Animancer
Containing Type
AnimancerState

Syntax

public bool Events(Object owner, out AnimancerEvent.Sequence events)

Remarks

This method tries to ensure that the event sequence is only referenced by this state.
  • If the reference was null, a new sequence will be created.
  • If a reference was assigned to , it will be cloned so this state owns the clone.
In both of those cases, this method returns true to indicate that the caller should initialize their event callbacks.

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

Documentation: Animancer Events

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

...

AnimancerState state = animancerComponent.Play(animation);
if (state.Events(this, out AnimancerEvent.Sequence events))
{
    events.SetCallback(EventName, OnAnimationEvent);
    events.OnEnd = OnAnimationEnded;
}
If you only need to initialize the End Event, consider using Animancer.AnimancerState.Events(System.Object) instead.

Parameters

Name Type Description
owner Object
events AnimancerEvent.Sequence

Return Value

Type Description
bool