Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Calling PlayableDirector.Evaluate() starts playback

Discussion in 'Timeline' started by dseyb, Jun 23, 2017.

  1. dseyb

    dseyb

    Joined:
    Jan 24, 2014
    Posts:
    9
    Hi everyone,
    We're integrating timeline into our runtime tool and for that we are building a "scrubber" which lets you set the current time of a PlayableDirector.

    For this, we first set PlayableDirector.time and then call PlayableDirector.Evaluate() to make sure that the timeline is actually "applied".
    It seems like the first time you call PlayableDirector.Evaluate() on an instance of PlayableDirector it starts playing back.
    Is there something we are doing wrong here?

    Cheers, Dario
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Hi,

    You uncovered a bug with Evaluate() in PlayMode. I've filed a bug and we will get it fixed, but in the meantime you can call PlayableDirector.Pause() after the first Evaluate() to work around it.

    Cheers
     
  3. dseyb

    dseyb

    Joined:
    Jan 24, 2014
    Posts:
    9
    Just as an update, a far more important thing is that calling Evaluate will *always* causes "OnBehaviourPlay" to be called on playable behaviors in the graph, but it does not cause a matching "OnBehaviourPause" to be called. We start playing an AudioSource in OnBehaviourPlay and want to pause it in OnBehaviourPause. The issue with Evaluate causes it to start playing when you seek in our timeline UI (which calls Evaluate). PlayableDirector.Pause doesn't do anything because the PlayableState of the director stays "Paused". Also, time isn't actually advancing after OnBehaviourPlay gets called due to Evaluate.
    I'd expect that OnBehaviourPlay actually means that the playable started playing. If it has to get called on Evaluate. I'd expect OnBehaviourPause to be called right away so you never get an OnBehaviourPlay without a matching OnBehaviourPause.
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    OnBehaviourPlay gets called when the time of the playable director is within the bounds of the clip (and the previous evaluated time wasn't), and OnBehaviourPause gets called when time it is outside (and previously wasn't), regardless of whether Evaluate() or regular playback is enabled. Is that the behaviour you are seeing?