Consider Checking info.DeltaTime
Closed this issue · 0 comments
In TimelineEventBehaviour.OnBehaviourPlay consider checking info.deltaTime to make sure its > 0 before invoking the method.
If the method pointed to by the TimelineEvent pauses the PlayableDirector (either directly or indirectly) the timeline will never be able to continue. This is because the moment PlayableDirector resumes, the TimelineEvent will get triggered again. This will immediately invoke the same method, which will immediately pause the timeline. The timeline will never be able to proceed past the current frame.
I tried checking info.frameId, but this number seems to keep incrementing even though it's truly playing the same frame over and over. The only way I could determine that the same frame was being played after resume was to check info.deltaTime. The only problem with this approach is if something is scheduled at the very first frame (frame 0). So here's what I propose:
public override void OnBehaviourPlay(Playable playable, FrameData info)
{
// Only invoke if time has passed to avoid invoking
// repeatedly after resume
if ((info.frameId == 0) || (info.deltaTime > 0))
{
UpdateDelegates();
if (invocationInfo != null)
{
invocationInfo.Invoke(IsMethodWithParam, ArgValue);
}
}
}