merge scene in the editor

hi.
i have 2 scenes in my project.
how do i add everything from scene 1 to scene 2?

For @frankyboy450 and any others who are still confused about how to implement this… (the Unity Script Reference isn’t quite as useful as it might be as it only shows part of the script you’ll need, and provides no help on where to put it.)

First create an Editor folder in your Assets, if one doesn’t already exist. Inside that create a new C# script:

55327-unity-editor-script.png

Name the file the same as your class name, for example AddScene.cs

Here’s the full code you’ll need:

using UnityEngine;
using UnityEditor;
using System.IO;
    
public class AddScene
{
    // Simple script that lets you load the contents of a selected scene 
    // to your current scene.

    [@MenuItem("Example/Load Scene Additive")]
    static void Apply()
    {
        string strScenePath = AssetDatabase.GetAssetPath(Selection.activeObject);
        if (strScenePath == null || !strScenePath.Contains(".unity"))
        {
            EditorUtility.DisplayDialog("Select Scene", "You Must Select a Scene!", "Ok");
            EditorApplication.Beep();
            return;
        }
        Debug.Log("Opening " + strScenePath + " additively");
        EditorApplication.OpenSceneAdditive(strScenePath);
    }
}

Note the use of EditorApplication.OpenSceneAdditive(strScenePath); as per the answer given above.

What this does is add a new item in your editor: [@MenuItem("Example/Load Scene Additive")]

55330-unity-editor-new-item.png

The above code is straight from the Unity Script Reference (http://docs.unity3d.com/ScriptReference/EditorApplication.OpenSceneAdditive.html)

I found another slightly more elegant implementation on GitHub (https://gist.github.com/AngryAnt/6192566) which places the item under the File menu. ‘Combine Scenes’ remains greyed out until you select two scenes in your Project window:

using UnityEngine;
using UnityEditor;
using System.IO;

public class AddScene
{
    [MenuItem("File/Combine Scenes")]
    static void Combine()
    {
        Object[] objects = Selection.objects;

        EditorApplication.SaveCurrentSceneIfUserWantsTo();
        EditorApplication.NewScene();

        foreach (Object item in objects)
        {
            EditorApplication.OpenSceneAdditive(AssetDatabase.GetAssetPath(item));
        }
    }


    [MenuItem("File/Combine Scenes", true)]
    static bool CanCombine()
    {
        if (Selection.objects.Length < 2)
        {
            return false;
        }

        foreach (Object item in Selection.objects)
        {
            if (!Path.GetExtension(AssetDatabase.GetAssetPath(item)).ToLower().Equals(".unity"))
            {
                return false;
            }
        }

        return true;
    }
}

I hope that’s useful to someone :slight_smile:

In an editor script, use

EditorAppliction.OpenSceneAdditive("Path/To/Scene.unity");

Then, just save normally and the two will have become one!

never mind. i figures out how to do it anyway