BeforeSceneLoad → Awake → OnEnable → OnLoad
→ Start → FixedUpdate → Update → LateUpdate
OnApplicationQuit → OnDisable → OnDestroy
StartUp.csUnity記事: 目次
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
using UnityEngine; /// <summary> /// /// Unity 2018.2.10f1 /// /// GameObjectにアタッチしておく必要はない /// /// </summary> public class StartUp : MonoBehaviour { [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] private static void BeforeSceneLoad() { Debug.Log("BeforeSceneLoad"); } [RuntimeInitializeOnLoadMethod] private static void OnLoad() { Debug.Log("OnLoad"); } } |
ExecutionOrderTest.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
using UnityEngine; /// <summary> /// /// Unity 2018.2.10f1 /// /// </summary> public class ExecutionOrderTest : MonoBehaviour { int count = 0; private void Awake() { Debug.Log("Awake"); } private void OnEnable() { Debug.Log("OnEnable"); } // Use this for initialization private void Start() { Debug.Log("Start"); } private void FixedUpdate() { if (count >= 1) { return; } Debug.Log("FixedUpdate"); } // Update is called once per frame private void Update() { if (count >= 1) { return; } Debug.Log("Update"); } private void LateUpdate() { if (count >= 1) { return; } Debug.Log("LateUpdate"); count++; } private void OnApplicationQuit() { Debug.Log("OnApplicationQuit"); } private void OnDisable() { Debug.Log("OnDisable"); } private void OnDestroy() { Debug.Log("OnDestroy"); } } |