Unity raises this event when the Player application wants to quit.
向此事件添加一个事件处理程序,以便接收关于应用程序试图退出的通知。
引发此事件时,退出过程已开始但可以取消。这意味着播放器并不保证退出。有关保证退出事件,请查看 Application.quitting。
Returns true and the quit process continues.
Returns false and the quit process cancels.
Note: The return value of this event is ignored when exiting Play mode in the Editor.
Important: The return has no effect on iOS or iPadOS. Application can not prevent termination under iOS or iPadOS.
using UnityEngine;
public class PlayerWantsToQuitExample { static bool WantsToQuit() { Debug.Log("Player prevented from quitting."); return false; }
[RuntimeInitializeOnLoadMethod] static void RunOnStart() { Application.wantsToQuit += WantsToQuit; } }
另请参阅:Application.quitting。