Search Unity

Set duration from custom inspector

Discussion in 'Timeline' started by GeniusKoala, Dec 2, 2021.

  1. GeniusKoala

    GeniusKoala

    Joined:
    Oct 13, 2017
    Posts:
    97
    Hi!

    I created a custom Playable to read an animation from a CSV file in a timeline. I would like to set the duration when the user chooses a file. I just don't know how to change the duration. If possible I would like to set the default duration of the clip directly because we often use the shortcut 'C' to resize the clip to its duration.

    upload_2021-12-2_16-14-38.png

    My custom clip has a duration field but it is not settable.

    upload_2021-12-2_16-16-39.png

    I am used to work with RecordClip that I create from a track from script (which I don't do here) and I can cast it to a TimelineClip which I can change the duration :


    TimelineClip clip = RecorderTrack.CreateClip<RecorderClip>();


    upload_2021-12-2_16-19-36.png

    If only I could wast my CustomClip to a TimelineClip I think it would work but I can't.

    upload_2021-12-2_16-26-13.png

    Finally I don't know how to set the duration from the CustomInspector (in the OnInspectorGUI() function) if anyone could help me please!

    EDIT : Anyone knows how to access the track of a clip from the clip? I need the track in the CustomEditor of my clip.
     
    Last edited: Dec 2, 2021