AnimancerState.

TryInitializeEvents(AnimancerEvent.Sequence) Method

Summary

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

Syntax

public bool TryInitializeEvents(out AnimancerEvent.Sequence events)

Remarks

In general, the first time this method is called on a particular state it will return true to indicate that the `events` are not initialized yet so the caller can configure them.

More specifically:
  • If the haven't already been assigned, this method will acquire a spare from the and return true.
  • If the have already been assigned, this method will do the same as above and also copy the assigned `events` into the new sequence so the caller can configure them for this state without affecting the original source of the events.
  • If this state already owns its events (because this method was already called or the property was accessed), this method will output null and return false.

Documentation: Animancer Events

Example:
var state = animancerComponent.Play(animationClipOrTransition);
if (state.TryInitializeEvents(out var events))
{
    events.SetCallback("Event Name", OnAnimationEvent);
    events.OnEnd = OnAnimationEnded;
}
If you only need to initialize the End Event, consider using the Animancer.AnimancerState.Events example instead.

Parameters

Name Type Description
events AnimancerEvent.Sequence

Return Value

Type Description
bool

See Also

  • Animancer.AnimancerState.Events
  • Animancer.AnimancerState.SharedEvents