SetPlayerLoop(PlayerLoopSystem)
Set a new custom update order for all engine systems in Unity.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Method
- Namespace: UnityEngine.LowLevel
- Assembly: UnityEngine.CoreModule
public static void SetPlayerLoop(PlayerLoopSystem loop)
Parameters
Remarks
Use to specify a custom update order for the Player loop. The PlayerLoopSystem supplied as the 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.
SetPlayerLooploopOnly 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 system in the Player loop. The custom system's is assigned the method, which prints a message to the console when it runs.
PreLateUpdateupdateDelegateCustomUpdateAdditional Resources: PlayerLoopSystem.
Examples
{code Documentation/ManualDocs/com.unity.documentation-examples/CoreProgramming/Scripts/PlayerLoop/PlayerLoopSetPlayerLoop.cs#example}