Version: 2023.1
public static void Quit ();

参数

exitCode 播放器应用程序在 Windows、Mac 和 Linux 上终止时返回的可选退出代码。默认值为 0。

描述

退出播放器应用程序。

关闭正在运行的应用程序。编辑器中会忽略 Application.Quit 调用。

如果在其他应用程序中运行 Unity 时要使用 Application.Quit,请参阅 UnityasaLibrary-Android 将 Unity 作为库使用 手册页面以了解更多信息。

Some platforms like Android and iOS have their own dedicated interfaces to hide and close applications. Users recognize these interfaces as the way to close applications so it's best practice to not create your own with Application.Quit. If you do, there will be an inconsistent user experience between your application and others on these platforms. If you must programmatically quit an Android application, you should instead move the application to the background via Activity.moveTaskToBack. For more information, refer to Quit a Unity Android application.

using UnityEngine;
using System.Collections;

// Quits the player when the user hits escape

public class ExampleClass : MonoBehaviour { void Update() { if (Input.GetKey("escape")) { Application.Quit(); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961