Description

Unity raises this event when Player is unloading.

Add an event handler to this event if you want to react to Application.Unload calls. The event is raised after a call to Application.Unload is made, right before the unloading starts.

Note: Application.unloading event is only supported on iOS, Android, and Universal Windows Platform.

using UnityEngine;
using System.Collections;

// Unload Unity when the user clicks the button. Exit is not applied to the application.

public class ExampleClass : MonoBehaviour { void OnGUI() { if (GUI.Button(new Rect(10, 10, 200, 75), "Unload")) Application.Unload(); }

static void OnUnload() { Debug.Log("Unloading the Player"); }

[RuntimeInitializeOnLoadMethod] static void RunOnStart() { Application.unloading += OnUnload; } }

See Also: Application.Unload.

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