Search Unity

Accessing clip end time

Discussion in 'Timeline' started by tree_fiddler_2000, Jan 24, 2019.

  1. tree_fiddler_2000

    tree_fiddler_2000

    Joined:
    Dec 5, 2018
    Posts:
    15
    Hi,

    I have custom tracks/behaviours/assets, and would like to able to skip to the current clip based off in-game events. For example, if I have a 10 second clip, I would like to able to skip it by pressing the space key. It seems like the easiest way to do this, in theory, is to set the Playable Director's current time to the clip's end time, however, I can't seem to access TimelineClip from PlayableBehaviour.

    I understand I can access the TimelineClips from the TrackAsset, but there doesn't seem to be a straightforward or reliable way to match up the clips to assets or behaviors, or is there?
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    No there isn't. The workaround is copy the data you need (e.g. end time) in your CustomTrack.CreateTrackMixer() from each clip to it's custom clip type (clip.asset). Then in your CustomClip.CreatePlayable, pass the information to the behaviour after you create it.
     
  3. tree_fiddler_2000

    tree_fiddler_2000

    Joined:
    Dec 5, 2018
    Posts:
    15
    Thanks, seant. Is it guaranteed that there is a 1-to-1 relationship between the clips and assets? ie. multiple clips won't reuse the same asset?
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    For the most part, yes. Unless you explicitly share assets then that's true. None of the built in tracks or samples do that.