I was wondering what the expected behaviour of the PlayableBehaviour callbacks are e.g. OnBehaviourPlay. This is especially confusing with the handling of both Edit-time/Run-time.
I’m new to Timeline and the PlayableGraph, so at the moment the problem I’m coming up against is when calling PlayableDirector.Pause/PlayableDirector.Resume.
Essentially, I would like to be able to differentiate between when a Playable is paused because it’s finished playing and when it’s paused because the PlayableDirector is paused. Is there a way to do that?
My current hack is to:
On Play/First Frame, save the director’s current time
On Pause, see if the clip is over by assessing the startTime + playable.GetDuration() > time
There is also the mysterious IsDone() flag which seems to never get set (in my brief testing).
In general it would be great to get a rundown of when:
OnBehaviourPause
OnBehaviourPlay
OnProcessFrame
OnGraphStart
OnGraphStop
[reliably] get called, and in which order. I noticed OnGraphStop gets called when the director pauses, and OnBehaviourPause seems to get called when the scene loads (although I haven’t fully tested/isolated that to confirm).
Apologies if these are basic questions, this is my first experience with Timeline and am looking to see how to fit it into our current workflow.
After playing around with it a bit more I think I have “working” solution which is to use the director’s play state. So, if OnBehaviourPause is called, then:
if the director is paused, it means pause
if the director is playing, it means over
I haven’t tested this thoroughly for it to be reliable, but logically (assuming the definition of OnBehaviourPause) it would seem to work.
OnBehaviourPause - Called when the clip becomes deactivated. This occurs when the timeline starts, when the clip is passed it’s duration, or if the timeline is stopped.
OnBehaviourPlay - Called when the clip activates. This may be preceded by a Pause call when the timeline starts even if the clip is on the first frame
OnProcessFrame - Called every frame the clip is active.
OnGraphStart - Called when the timeline starts playing, or before the first evaluate.
OnGraphStop - Called when the timeline stops playing.
OnGraphStart and OnGraphStop can be quite deceiving in Editor because the underlying PlayableGraph (which is the instance of the timeline) is frequently rebuild as the timeline is edited.
Necroposting, but just wanted to say that I’ve seen OnBehaviourPause not being called after the clip ends, but only when the timeline starts. It happens, but not all the time. Clip is small, 3 frames duration if that helps.
This is too counterintuitive! Why would OnBehaviourPause be called when the timeline starts playing? I think the programmers responsible for designing the lifecycle architecture should be kicked out.
Is there are reliable way to use OnBehaviourPause as clips end? It gets called when the timeline starts as well…
So It’d be fine if there is some condition to check if it is when timeline starts or clip ends
public override void OnBehaviourPause(Playable playable, FrameData info){
// check where we are
}