Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[solved] Getting TrackClipType from a TrackAsset/ClipAsset

Discussion in 'Timeline' started by hoperin, Jul 18, 2018.

  1. hoperin

    hoperin

    Joined:
    Feb 9, 2014
    Posts:
    52
    I'm setting up a system that duplicates my generated timelines and moves clips around depending on changes made during the generation process, which means I am iterating through all the tracks on a given Timeline, picking out the clips i want to migrate, and create new tracks and new clips on a new timeline.

    Where I'm stuck is getting from TrackAsset/TimelineClipAsset to TrackClipType, so that I can do multiple thigns, like exclude certain tracks, create new tracks on the new timeline of the correct track type, etc. I'm iterating through the tracks and the clips on said tracks with TimelineAsset.GetOutputTracks() and TrackAsset.GetClips() but these all target the Assets when really i need to find the type info at some point in this process.

    I'm actually unsure how to target TrackClipType at all. I tried track.TrackClipType, track.TrackClipType(), etc, but its unclear to me from the documentation what format this info is actually in / how to access it.

    Here's where I've gotten to:

    Code (CSharp):
    1.     void ClipMatchFound(TimelineClip oldClip, TimelineClip newClip) {
    2.  
    3.         Debug.Log("MATCH FOUND FOR:" + oldClip.displayName + " in " + newClip.displayName);
    4.  
    5.         //go thru each track on the old timeline we are copying form
    6.         foreach (TrackAsset track in oldTL.GetOutputTracks())
    7.         {
    8.             //does not currently work but find a way to skip the knot and ink clip tracks depending on their track type...
    9.             //if (track.Type != Ink_StateClipTrack)
    10.             //{
    11.  
    12.             //go thru every dang clip on the track
    13.             foreach (TimelineClip clip in track.GetClips())
    14.                 {
    15.              
    16.                 //if clip starts at exact same time
    17.                 if (clip.start == oldClip.start)
    18.                     {
    19.                        
    20.                         //copy the dang clip yall
    21.                         break;
    22.  
    23.                         //else if clip is encapsulted by oldclip
    24.                     }
    25.                     else if (clip.start >= oldClip.start && (clip.start + clip.duration) <= (oldClip.start + oldClip.duration))
    26.                     {
    27.                        
    28.                         //copy the dang clip yall
    29.                         break;
    30.  
    31.                     }
    32.                 }
    thanks in advance!
     
  2. hoperin

    hoperin

    Joined:
    Feb 9, 2014
    Posts:
    52
    and of course as soon as i finally give in and make a forum post, i figure out the very easy solution. posting here for others:

    TrackAsset track;
    track.GetType();

    TimelineClip clip;
    clip.asset.GetType();

    will return the track type and clip type respectively
     
    Immu likes this.