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

GetBehaviour() from a new default TimelineClip

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

  1. Vezmo

    Vezmo

    Joined:
    Aug 4, 2017
    Posts:
    6
    Hi!

    I managed to create X number of timeline default clips through an Editor Button by using TrackAsset.CreateDefaultClip() and when I click on them through the inspector, I see that they have the good TrackClipTypeAttribute (it's a dialogue box track that creates dialogue box clips that have a field supposed to contain text).

    However, by creating default clips, I'm stuck with X number of TimelineClips and I can't seem to be able to reach their custom properties (the text field) through code.

    What I'm saying here is that I can't reach the fields of my custom clips through code. My script only sees them as TimelineClips but the inspector knows that they have a text field.

    Am I missing a cast or something?

    Thank you!!
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    The field you are looking for is TimelineClip.asset. It points to an instance of the class you specified in the TrackClipTypeAttribute.

    Code (CSharp):
    1. var myAsset = clip.asset as MyCustomClipType;
    2. myAsset.myText = "blah";
    3.            
    4.  
     
  3. Vezmo

    Vezmo

    Joined:
    Aug 4, 2017
    Posts:
    6
    I feel bad... The answer was right in my face. Thank you so so so much!