Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

Tips and tricks for using PlayableDirector in Manual update mode

Discussion in 'Timeline' started by doctorpangloss, Aug 4, 2019.

  1. doctorpangloss

    doctorpangloss

    Joined:
    Feb 20, 2013
    Posts:
    255
    The documentation on this is pretty sparse and infuriating so I'm including the completely undocumented things you need to do to actually control a PlayableDirector manually.

    The main thing you're probably missing is that you always call
    Code (CSharp):
    1. playableDirector.DeferredEvaluate()
    once per frame.

    • Set your Update Mode to Manual.
    • In an Update function, call
      Code (CSharp):
      1. playableDirector.DeferredEvaluate();
    • If you want to advance the whole director, use
      Code (CSharp):
      1. playableDirector.time += yourDeltaTime
      .
    • If you want to use the PlayableGraph object, for whatever reason, you must rebuild the graph at least once (try doing it in Start / Awake) or whenever your playable asset changes:
      Code (CSharp):
      1. playableDirector.RebuildGraph();
      2. playableDirector.playableGraph.SetTimeUpdateMode(DirectorUpdateMode.Manual);
     
  2. WendelinReich

    WendelinReich

    Joined:
    Dec 22, 2011
    Posts:
    226
    Glad you took the time to document this doctorpangloss. Is there a reason why you recommend calling DeferredEvaluate instead of Evaluate? The former doesn't seem to be compatible with the Play mode in the editor.
     
unityunity