美文网首页
代码创建场景

代码创建场景

作者: 泱千澈 | 来源:发表于2019-10-22 15:44 被阅读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
        }
    }
    

    相关文章

      网友评论

          本文标题:代码创建场景

          本文链接:https://www.haomeiwen.com/subject/nsagyctx.html