Documentation

Unity Engine

Download Unity

Unity Engine

GatherAnimationEvents

Appends the animation events that a timer crossed during its last update to a list.
Read time 4 minutesLast updated 5 hours ago

Definition

GatherAnimationEvents(Clip, TimerState, NativeList<GatheredAnimationEvent>)

Appends the animation events that a timer crossed during its last update to a list.
public static void GatherAnimationEvents(ref Clip clip, in TimerState timer, NativeList<GatheredAnimationEvent> events)

Parameters

clip

The clip that holds the animation events to gather.

The clip timer, updated for the frame. Its range must be inside the clip.

The list to append the gathered events to.

Remarks

Use this method with a clip timer from Clip.ToTimerState, after you update the timer. The timer holds the time on the curves of the clip. The events therefore use the same time as the pose that ClipSampler samples from the timer, including the start time, the stop time, and the cycle offset of the clip.
The method gathers the events after TimerState.PreviousTime, up to and including TimerState.Time. When the timer loops, the method gathers the events once for each cycle that the timer crossed. A frame that spans several loops therefore returns the events of every loop. A timer that has a negative TimerState.TimeScale plays backward and returns the events in descending time order. When the wrap mode is WrapMode.PingPong, the timer turns around at the ends of the range. It returns an event at an end once. The method doesn't gather events when the timer is paused or stopped, or when its delta time is 0.
The method includes the events at
TimerState.PreviousTime
in the following cases, so that an event at the start of the clip isn't missed:
The method appends the events in playback order and doesn't clear the list first.

GatherAnimationEvents(Clip, DiscreteTime, DiscreteTime, NativeList<GatheredAnimationEvent>)

Appends the animation events that a clip crosses between two playback times to a list.
public static void GatherAnimationEvents(ref Clip clip, DiscreteTime from, DiscreteTime to, NativeList<GatheredAnimationEvent> events)

Parameters

clip

The clip that holds the animation events to gather.

The start of the range, in seconds from the start of the clip.

The end of the range, in seconds from the start of the clip.

The list to append the gathered events to.

Remarks

Use this method when you track the playback time of the clip yourself. The times are playback times from the start of the clip, as in ClipSampler.Sample. The method creates a clip timer at
from
, advances it to
to
, and passes it to AnimationEventUtility.GatherAnimationEvents, so the events are the ones that the sampled pose crosses.
When
from
is greater than
to
, the clip plays backward from
from
to
to
. To step forward over the end of a looping clip, pass a
to
that is greater than the length of the clip. The range can span any number of loops. The range excludes
from
and includes
to
, except that a
from
of 0 includes the events at the start of the clip.

GatherAnimationEvents(BlobObjectReference<Clip>, TimerState, NativeList<GatheredAnimationEvent>)

Appends the animation events that a timer crossed during its last update to a list.
public static void GatherAnimationEvents(BlobObjectReference<Clip> clip, in TimerState timer, NativeList<GatheredAnimationEvent> events)

Parameters

The reference to the clip that holds the animation events to gather. It must be valid.

The clip timer, updated for the frame. Its range must be inside the clip.

The list to append the gathered events to.

Remarks

This method behaves like AnimationEventUtility.GatherAnimationEvents. Use it with the reference that AnimationClipExtensions.ToClipReference returns, or with ClipSampler.Clip, instead of passing its
Value
.

GatherAnimationEvents(BlobObjectReference<Clip>, DiscreteTime, DiscreteTime, NativeList<GatheredAnimationEvent>)

Appends the animation events that a clip crosses between two playback times to a list.
public static void GatherAnimationEvents(BlobObjectReference<Clip> clip, DiscreteTime from, DiscreteTime to, NativeList<GatheredAnimationEvent> events)

Parameters

The reference to the clip that holds the animation events to gather. It must be valid.

The start of the range, in seconds from the start of the clip.

The end of the range, in seconds from the start of the clip.

The list to append the gathered events to.

Remarks

This method behaves like AnimationEventUtility.GatherAnimationEvents. Use it with the reference that AnimationClipExtensions.ToClipReference returns, or with ClipSampler.Clip, instead of passing its
Value
.