Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted The most optimal way to Set Binding reliably?

Discussion in 'Timeline' started by cdr9042, Sep 25, 2020.

  1. cdr9042


    Apr 22, 2018
    So I'm trying to set a track to bind to a component during runtime. I expected the track to always be the second track in the GetOutput arrays
    Code (CSharp):
    1. playableDirector.SetGenericBinding(currentTimeline.GetOutputTrack(1), this);
    But this does not always work. For some reasons, the track is sometime at position 0, sometime at 1. So turn out, there is a Marker track that sometimes appear in the outputs array, even though my timelines do not have any markers in that track.
    To reproduce this, I find out that if I add a marker to the Marker track, and then delete the marker, that timeline will have that Marker track added at position 0 in outputs array.

    So my method is prone to error. Is there any way to set binding correctly without having to iterate through every track to get the correct one? I'm trying to find the most optimal way
  2. seant_unity


    Unity Technologies

    Aug 25, 2015
    Before calling SetGenericBinding, Make sure the marker track exists using CreateMarkerTrack() - it will only create it if it doesn't exist. The marker track always is at index 0 when it exists, which will make the index of all other tracks consistent.
    cdr9042 likes this.