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
- Type: Method
- Namespace: Unity.Animations
- Assembly: UnityEngine.AnimationCoreModule
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
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 in the following cases, so that an event at the start of the clip isn't missed:
TimerState.PreviousTime-
The update is the first update of a timer fromwith a time of 0.
Clip.ToTimerState -
The timer was stopped during the previous update.
-
The timer was rewound with TimerStateExtensions.Rewind or moved with TimerStateExtensions.JumpToTime since the previous update.
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
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 , advances it to , and passes it to AnimationEventUtility.GatherAnimationEvents, so the events are the ones that the sampled pose crosses.
fromtoWhen is greater than , the clip plays backward from to . To step forward over the end of a looping clip, pass a that is greater than the length of the clip. The range can span any number of loops. The range excludes and includes , except that a of 0 includes the events at the start of the clip.
fromtofromtotofromtofromGatherAnimationEvents(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 .
ValueGatherAnimationEvents(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