0
\$\begingroup\$

On Button click at editor mode I am trying to make a scene of selected Hierarchy game-object but the problem is as i click the button new scene become upon and I lost the scene where i were selected the Game-object. My code given below:

 if (GUILayout.Button("Generate Scene"))
        {
            Scene newScene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);;
            SceneManager.MoveGameObjectToScene(Selection.activeGameObject, newScene);
            EditorApplication.SaveScene("Assets/RegionScene/" + gameObjectSelected[gameObjectSelected.Count - 1].name + ".unity"); //newScene

        }
\$\endgroup\$
  • \$\begingroup\$ ...and what would you like to happen instead? \$\endgroup\$ – Philipp May 6 '16 at 14:27
0
\$\begingroup\$

Sounds like you want to use NewSceneMode.Additive to create the new scene without discarding the currently open scene(s).

Pass this as the second parameter of the NewScene() method.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.