Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

How to refresh/update the timeline through code

Discussion in 'Timeline' started by Dima-Kurilchenko, Oct 31, 2019.

  1. Dima-Kurilchenko

    Dima-Kurilchenko

    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,035
    PlayableDirector.RebuildGraph();
     
  3. Dima-Kurilchenko

    Dima-Kurilchenko

    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!