Created
August 14, 2020 16:32
Star
You must be signed in to star a gist
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
See also https://gist.github.com/LotteMakesStuff/8534e01043826754344a570a4cf21002
https://www.patreon.com/posts/unity-2018-1-16336053