Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Question 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.