-
方法一
调用菜单命令
EditorApplication.ExecuteMenuItem("File/New Scene");
EditorApplication中有不少有用的函数
-
方法二
调用NewScene函数
Scene scene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
其中枚举NewSceneSetup和NewSceneMode的定义如下
namespace UnityEditor.SceneManagement
{
//
// 摘要:
// Used when creating a new scene in the Editor.
public enum NewSceneSetup
{
//
// 摘要:
// No game objects are added to the new scene.
EmptyScene = 0,
//
// 摘要:
// Adds default game objects to the new scene (a light and camera).
DefaultGameObjects = 1
}
}
namespace UnityEditor.SceneManagement
{
//
// 摘要:
// Used when creating a new scene in the Editor.
public enum NewSceneMode
{
//
// 摘要:
// All current open scenes are closed and the newly created scene are opened.
Single = 0,
//
// 摘要:
// The newly created scene is added to the current open scenes.
Additive = 1
}
}
网友评论