代码创建场景

2019-10-22  本文已影响0人  泱千澈

调用菜单命令

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
    }
}
上一篇 下一篇

猜你喜欢

热点阅读