-
-
Save Novack/6c5482074e7da541959b701a5bea6b1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.LowLevel; | |
using UnityEngine.PlayerLoop; | |
public static class AddPlayerLoopCallback | |
{ | |
// Add a callback to the PreUpdate phase | |
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] | |
static void Setup() | |
{ | |
var loop = PlayerLoop.GetCurrentPlayerLoop(); | |
for (int i = 0; i < loop.subSystemList.Length; ++i) | |
{ | |
if ( loop.subSystemList[i].type == typeof(PreUpdate)) | |
{ | |
loop.subSystemList[i].updateDelegate += Update; | |
} | |
} | |
PlayerLoop.SetPlayerLoop(loop); | |
} | |
static void Update() | |
{ | |
Debug.Log("PreUpdate"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment