Search Unity

How to refresh/update the timeline through code

Discussion in 'Timeline' started by Dkury, Oct 31, 2019.

  1. Dkury

    Dkury

    Joined:
    Jul 14, 2012
    Posts:
    46
    Hi,

    I'm creating group tracks, tracks, and clips through code. After creating a group (GroupTrack), the timeline does not always update and "know" about changes. So in order to play the timeline with the changes, I have to re-open the "Timeline" window.

    What is the best way to refresh the timeline through code without using any editor scripts? Say, if I'm constructing the timeline entirely in runtime (outside of the editor) and want to play it back with all the changes immediately.

    I'm using Unity 2019.1.2f1.

    Thank you.
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    PlayableDirector.RebuildGraph();
     
    Alesta88 likes this.
  3. Dkury

    Dkury

    Joined:
    Jul 14, 2012
    Posts:
    46
    I've seen it in the API reference but assumed that it fully discards the graph and returns it without data and bindings.

    Didn't notice that in the documentation it actually says "Use this method when the assigned PlayableAsset has changed and it is necessary to show the changes during playback".

    Thank you!