This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
runtimeinitializeonload [2021/04/14 03:18] 73.95.178.156 |
runtimeinitializeonload [2021/08/31 14:55] 73.95.178.156 |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
The documentation is not correct about this function running after awake. It does by default, but not if you specify a load type: | The documentation is not correct about this function running after awake. It does by default, but not if you specify a load type: | ||
- | The order of callbacks is: ((tested in the editor, 2020.2.1f1)) | + | The order of callbacks is: ((tested in the editor, 2020.2.1f1 |
* SubsystemRegistration | * SubsystemRegistration | ||
* AfterAssembliesLoad | * AfterAssembliesLoad | ||
Line 11: | Line 11: | ||
* AfterSceneLoad, | * AfterSceneLoad, | ||
- | Providing no load type defaults to running the function after Awake. | + | Providing no load type defaults to RuntimeInitializeLoadType.AfterSceneLoad, |
+ | |||
+ | Other versions that have been verified to also use this exact order: | ||
+ | * 2021.1.12f1 (editor only) | ||
+ | |||
+ | Methods with RuntimeInitializeLoadType.AfterSceneLoad, | ||
+ | ---- | ||
+ | |||
+ | ===== Other Nuanced Info ===== | ||
+ | |||
+ | If you create a GameObject and attach a MonoBehaviour to it in " | ||
+ | |||
+ | Example: | ||
+ | <code cs> | ||
+ | [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] | ||
+ | static void AutoRun() { | ||
+ | GameObject obj = new GameObject(" | ||
+ | } | ||
+ | </ | ||
+ | ---- | ||
+ | |||
+ | [[https:// |