Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SetPlayerLoop(PlayerLoopSystem)

Set a new custom update order for all engine systems in Unity.
Read time 1 minuteLast updated 6 days ago

Definition

public static void SetPlayerLoop(PlayerLoopSystem loop)

Parameters

Remarks

Use
SetPlayerLoop
to specify a custom update order for the Player loop. The PlayerLoopSystem supplied as the
loop
parameter becomes the new current Player loop returned by PlayerLoop.GetCurrentPlayerLoop. The new update order does not take effect until the next full Player loop iteration, but the changes are immediately visible in subsequent calls to PlayerLoop.GetCurrentPlayerLoop.
Only systems included in the new Player loop will run. You can insert custom script entry points in the update order before setting it. For example, this allows you to add a script that runs immediately before physics, or in other places where scripts are not run by default.
The following example inserts a custom Player loop system that runs after the
PreLateUpdate
system in the Player loop. The custom system's
updateDelegate
is assigned the
CustomUpdate
method, which prints a message to the console when it runs.
Additional Resources: PlayerLoopSystem.

Examples

{code Documentation/ManualDocs/com.unity.documentation-examples/CoreProgramming/Scripts/PlayerLoop/PlayerLoopSetPlayerLoop.cs#example}