Unity初始化函数以及退出函数的执行顺序

public class HanShuCeShi : MonoBehaviour {
    void Awake()
    {
        Debug.Log("Awake");
    }
   
    // Use this for initialization
    void Start () {
        Debug.Log("Start");
    }
	
	// Update is called once per frame
	void Update () {
		
	}
    

    
    void OnEnable()
    {
        Debug.Log("OnEnable");
    }

    void OnDisable()
    {
        Debug.Log("OnDisable");
    }

    void OnDestroy()
    {
        Debug.Log("OnDestroy");
    }

    void OnApplicationPause(bool pause)
    {
        Debug.Log("OnApplicationPause : pause = " + pause);
    }

    void OnApplicationQuit()
    {
        Debug.Log("OnApplicationQuit");
    }
}

打印结果:

红色  启动Unity       

 蓝色 Unity失去焦点 获得焦点 

绿色 停止Unity


猜你喜欢

转载自blog.csdn.net/lei_7103/article/details/71080903