info | The FrameData for the current frame. |
playerData | Custom data passed down the tree, specified in DirectorPlayer.Play. |
Evaluates the Playable with a delta time.
The ProcessFrame is the stage at which your Playable should do its work. This method is called every frame when a Playable tree is playing. The ProcessFrame method has 2 parameters, the current FrameData structure which describes the current time and the time delta, and a custom data object. This custom object is the data on which the Playable should do its work, as it is passed down the tree from Playable to Playable. This custom object is passed as a parameter to the Director.Play method.
public class SomeData { public int foobar = 0; public int increment = 1; }
public class MyCustomPlayable : Playable { public override void ProcessFrame(FrameData info, object customData) { var theData = customData as SomeData; theData.foobar += theData.increment; } }
public class SwapSign : Playable { public override void ProcessFrame(FrameData info, object customData) { var theData = customData as SomeData; if (theData.foobar > 20) theData.increment = -1; if (theData.foobar <= 0) theData.increment = 1; } }
public class GraphIncrementDecrement : MonoBehaviour { private SomeData myCustomData;
void Start() { var rootPlayable = new MyCustomPlayable() var childPlayable = new SwapSign();
Playable.Connect(childPlayable, rootPlayable);
GetComponent<DirectorPlayer>().Play(rootPlayable, myCustomData); }
void Update() { Debug.Log("foobar is now:" + myCustomData.foobar); } }