Version: 2023.2

描述

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

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961