Timeline Mixer Documentation
Loading...
Searching...
No Matches
Fade Events and Timeline Events

Why is there no OnComplete event?:

Timeline Mixer does not define a universal ‘completion’ condition for timelines. Timelines can be played in reverse, looped, and played beyond their duration (animation extrapolation), this makes a single, reliable definition of ‘complete’ impossible.

Instead, it provides callbacks (fade and timeline events) that can be composed to match your specific definition of completion, whether that is duration reached, beginning reached, or faded out, or another condition.

Timeline based events

Callbacks can be added to a Timeline at a specified time using SetTimelineEvent:

TimelineMixerComponent timelineMixer = GetComponent<TimelineMixerComponent>();
float eventTime = 2f; // 2 seconds
timelineMixer.SetTimelineEvent(
timelineAsset,
eventTime,
() =>
{
timelineMixer.FadeOut(timelineAsset, 2f);
Debug.Log($"{timelineAsset.name} Event Fired!");
}
);

Alternatively:

Action callback = () =>
{
timelineMixer.FadeOut(timelineAsset, 2f);
Debug.Log($"{timelineAsset.name} Event Fired!");
};
timelineMixer.SetTimelineEvent(timelineAsset, eventTime, callback);

This registers a callback that will fire when the Timeline reaches the specified time.

Notes

  • Events are evaluated against the Timeline's playback time.
  • If the Timeline loops, events will fire again on subsequent loops.
  • Events cannot currently be removed individually.

To clear all events on a Timeline:

timelineMixer.ClearTimelineEvents(timelineAsset);

Fade-based events

Fade events are stored per Timeline and can be accessed via:

// By timeline name
timelineMixerComponent.GetFadeEvents("Happy");
// By TimelineAsset reference
timelineMixerComponent.GetFadeEvents(timelineAsset);

These callbacks persist for as long as the Timeline is registered within the Timeline Mixer. If the Timeline is removed at runtime, all runtime information related to the timeline, including these callbacks, will be destroyed.

Subscribing to events

var events = timelineMixerComponent.GetFadeEvents("Happy");
events.OnFadeInStart += () => Debug.Log("FADE IN START");
events.OnFadeOutStart += () => Debug.Log("FADE OUT START");
events.OnFadeUpdate += (progress, weight) =>
Debug.Log(progress + " " + weight);
events.OnFadeInComplete += () => Debug.Log("FADE IN COMPLETE");
events.OnFadeOutComplete += () => Debug.Log("FADE OUT COMPLETE");

Callback descriptions

  • OnFadeInStart / OnFadeOutStart: Invoked when a fade begins.
  • OnFadeUpdate: Invoked every frame while a fade is in progress. Provides: progress (0 → 1) weight (0 → 1)
  • OnFadeInComplete / OnFadeOutComplete: Invoked when the fade reaches its target weight.

Calling the Play method is considered a FadeIn, with a fade duration of 0 seconds. Play will fire OnFadeInStart, OnFadeUpdate (once), and OnFadeInComplete