| Parameter | Description |
|---|---|
| playable | The Playable that owns the current PlayableBehaviour. |
| info | A FrameData structure that contains information about the current frame context. |
This function is called during the PrepareData phase of the PlayableGraph.
Note: This method is obsolete and is not invoked by Unity anymore.
PrepareData is called as long as the playable is delayed.
using UnityEngine.Playables; public class DelayedBehaviour : PlayableBehaviour { public double Delay; public float LeadTime; private bool m_Started; public virtual void OnPrefetchData(Playable playable, FrameData info) {} public override void PrepareFrame(Playable playable, FrameData info) { if (m_Started) return; double remainingDelay = Delay - playable.GetTime(); for (int i = 0; i < playable.GetInputCount(); i++) { var input = playable.GetInput(i); input.SetSpeed(0.0); if (LeadTime >= remainingDelay) InvokePrefetchData(input, info); } if (remainingDelay <= 0.0) { m_Started = true; for (int i = 0; i < playable.GetInputCount(); i++) playable.GetInput(i).SetSpeed(playable.GetSpeed()); } } static void InvokePrefetchData(Playable playable, FrameData info) { if (typeof(DelayedBehaviour).IsAssignableFrom(playable.GetPlayableType())) ((ScriptPlayable<DelayedBehaviour>)playable).GetBehaviour()?.OnPrefetchData(playable, info); } }