Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


PrepareData(Playable, FrameData)

This function is called during the PrepareData phase of the PlayableGraph.
Read time 1 minuteLast updated 10 days ago

Definition

Warning
Deprecated. PrepareData is obsolete. This method was invoked as part of the Playable delay mechanism, which has now been fully deprecated. This method is no longer invoked by Unity and will be removed in a future version. You can emulate this functionality by implementing your own delay mechanism as part of a PlayableBehaviour.
public virtual void PrepareData(Playable playable, FrameData info)

Parameters

playable

The Playable that owns the current PlayableBehaviour.

A FrameData structure that contains information about the current frame context.

Remarks

Note: This method is obsolete and is not invoked by Unity anymore.
PrepareData is called as long as the playable is delayed.

Examples

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); }}