退出 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); } }