Created
March 8, 2021 15:04
-
-
Save hybridherbst/36ae70b6520981c8edc7b478423fae5e to your computer and use it in GitHub Desktop.
[RuntimeInitializeOnLoad] Event Order
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
static Lifecycle() => Debug.Log(Prefix + "Static Constructor"); | |
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] static void Subs() => Debug.Log(Prefix + "Subsystem Registration"); | |
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)] static void AfterAsm() => Debug.Log(Prefix + "AfterAssembliesLoaded"); | |
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)] static void BeforeSlash() => Debug.Log(Prefix + "Before Splash"); | |
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] static void BeforeScene() => Debug.Log(Prefix + "BeforeScene"); | |
private void Awake() => Debug.Log(Prefix + "Awake"); | |
private void OnEnable() => Debug.Log(Prefix + "OnEnable"); | |
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)] static void AfterScene() => Debug.Log(Prefix + "AfterSceneLoad"); | |
[RuntimeInitializeOnLoadMethod] static void DefaultLog() => Debug.Log(Prefix + "RuntimeInit Default"); | |
void Start() => Debug.Log("Start"); |
This is one of the top google results for this stuff, so I just wanted to direct people to the uninomicon page for RuntimeInitializeOnLoad: https://uninomicon.com/runtimeinitializeonload
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you very much for compiling this, helped me out out a ton tracking down a bug where the static initialization was happening after Unity lifecycle events!