Legacy Documentation: Version 5.2
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Playable.ProcessFrame

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public function ProcessFrame(info: Experimental.Director.FrameData, playerData: object): void;
public void ProcessFrame(Experimental.Director.FrameData info, object playerData);

Parameters

info The FrameData for the current frame.
playerData Custom data passed down the tree, specified in DirectorPlayer.Play.

Description

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