Documentation

Unity Engine

Download Unity

Unity Engine

Length

The duration of the clip in seconds, from its start time to its stop time.
Read time 1 minuteLast updated 4 hours ago

Definition

public float Length { get; }

Remarks

This is the duration that a ClipSampler plays, and the size of the TimerState.Range of the timer that Clip.ToTimerState returns.
AnimationClip.length
is the time at the end of the curves of the clip, not a duration, so it can differ from this value. The two values are the same only when Clip.StartTime is 0 and the stop time is the end of the last curve. They differ in the following cases:
  • Clip.StartTime isn't 0.
    AnimationClip.length
    is then at least the stop time, while this value is the stop time minus the start time.
  • The curves of the clip go past Clip.StopTime.
    AnimationClip.length
    reports the end of the curves, but the clip stops at Clip.StopTime.
  • In a player build, Unity can strip the curves of a clip.
    AnimationClip.length
    is then the stop time.
When you drive a ClipSampler, use Clip.StartTime, Clip.StopTime, and this property instead of
AnimationClip.length
.
Additional Resources: Clip.StartTime, Clip.StopTime