public static void Exit (int returnValue);

描述

退出 Unity 编辑器应用程序。

调用此函数将立即退出,而不要求保存更改,因此您可能会丢失数据! 此函数对于退出发生特定错误的命令行进程极为有用。


另请参阅:Unity 命令行参数

// Simple script that lets you create a new
// Scene, create a cube and an empty game object in the Scene
// Save the Scene and close the editor

using UnityEditor; using UnityEditor.SceneManagement;

public class ExampleClass { [MenuItem("Examples/Chain Actions and close")] static void EditorPlaying() { var newScene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);

EditorApplication.ExecuteMenuItem("GameObject/3D Object/Cube"); EditorApplication.ExecuteMenuItem("GameObject/Create Empty");

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