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

Accessing TrackAsset.CreateDefaultClip() from the same object with a Monobehaviour script

Discussion in 'Timeline' started by Vezmo, Aug 7, 2017.

  1. Vezmo

    Vezmo

    Joined:
    Aug 4, 2017
    Posts:
    6
    Hi! Is there a way to access the creation of a default clip of a particular TrackAsset through a Monobehaviour script

    I have a Monobehaviour script that has an Editor Button and it's attached to an object that has a timeline. On Click, I would like to create as many default clips in the timeline as there are elements in the Monobehaviour array.

    Can you please tell me what I'm missing? I can't seem to be able to find where to get the reference to trackasset through the playable director component. Here's a picture to clear things up.

    Would it be through GetGenericBinding()? If so, how does that work?

    upload_2017-8-7_11-25-17.png

    Thanks!
     
    Last edited: Aug 7, 2017
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    From the playableDirector you can cast the playableAsset field to a TimelineAsset.

    From the timeline asset, you can iterate over the tracks using GetOutputTracks().
     
    Vezmo likes this.
  3. Vezmo

    Vezmo

    Joined:
    Aug 4, 2017
    Posts:
    6
    Hey man, thank you so much! It worked! Have a good day!