Created
August 14, 2020 16:32
-
-
Save karljj1/fe0450fa1d5890665447eb09c4e3fee0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
See also https://gist.github.com/LotteMakesStuff/8534e01043826754344a570a4cf21002
https://www.patreon.com/posts/unity-2018-1-16336053