測試結果為關閉游戲,會調用OnDestroy().但OnApplicationQuit()比它提前調。

using UnityEngine; using System.Collections; public class NewBehaviourScript : MonoBehaviour { void OnApplicationQuit() { Debug.Log("111"); } void OnDestroy() { Debug.Log("222"); } }
輸出:
111
222