Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Custom playable track GetDuration() returns 0

Discussion in 'Timeline' started by BPSRyan, Aug 8, 2019.

  1. BPSRyan

    BPSRyan

    Joined:
    Oct 3, 2018
    Posts:
    4
    I've created a custom track asset and a custom track clip which work fine except for when I attempt to retrieve the duration of the clip like so;

    Code (CSharp):
    1. float progressRate = (float)playable.GetTime () / (float)playable.GetDuration();
    GetTime works fine and returns the current time in the clip but GetDuration returns 0.
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Is that playable for a clip or mixer? If it's the playable for a clip, that's odd, and likely a bug.

    The duration isn't set on a default mixer playable, but you could do that in CreateTrackMixer() if you need it. But, the time on a mixer playable isn't necessarily synced to the timeline time.
     
  3. ryanas

    ryanas

    Joined:
    Oct 2, 2013
    Posts:
    14
    Seems like it was an issue with a custom Playable track that was also adding an activation track to the graph. It seems by doing this, GetDuration() was returning 0.