测试结果为关闭游戏,会调用OnDestroy().但OnApplicationQuit()比它提前调。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
using UnityEngine;using System.Collections;public class NewBehaviourScript : MonoBehaviour{ void OnApplicationQuit() { Debug.Log("111"); } void OnDestroy() { Debug.Log("222"); }}
输出:
111
222
本文共 332 字,大约阅读时间需要 1 分钟。
测试结果为关闭游戏,会调用OnDestroy().但OnApplicationQuit()比它提前调。
using UnityEngine;using System.Collections;public class NewBehaviourScript : MonoBehaviour{ void OnApplicationQuit() { Debug.Log("111"); } void OnDestroy() { Debug.Log("222"); }}
输出:
111
222
转载于:https://www.cnblogs.com/hont/p/4166742.html