UnityEditor.Lightmapping.BakeMultipleScenes C# (CSharp) Method

BakeMultipleScenes() public static method

Bakes an array of scenes.

public static BakeMultipleScenes ( string paths ) : void
paths string The path of the scenes that should be baked.
return void
        public static void BakeMultipleScenes(string[] paths)
        {
            if (paths.Length != 0)
            {
                for (int i = 0; i < paths.Length; i++)
                {
                    for (int j = i + 1; j < paths.Length; j++)
                    {
                        if (paths[i] == paths[j])
                        {
                            throw new Exception("no duplication of scenes is allowed");
                        }
                    }
                }
                if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
                {
                    SceneSetup[] sceneManagerSetup = EditorSceneManager.GetSceneManagerSetup();
                    EditorSceneManager.OpenScene(paths[0]);
                    for (int k = 1; k < paths.Length; k++)
                    {
                        EditorSceneManager.OpenScene(paths[k], OpenSceneMode.Additive);
                    }
                    Bake();
                    EditorSceneManager.SaveOpenScenes();
                    EditorSceneManager.RestoreSceneManagerSetup(sceneManagerSetup);
                }
            }
        }