public static void BakeMultipleScenes(string[] paths)
{
if (paths.Length == 0)
{
return;
}
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())
{
return;
}
SceneSetup[] sceneManagerSetup = EditorSceneManager.GetSceneManagerSetup();
EditorSceneManager.OpenScene(paths[0]);
for (int k = 1; k < paths.Length; k++)
{
EditorSceneManager.OpenScene(paths[k], OpenSceneMode.Additive);
}
Lightmapping.Bake();
EditorSceneManager.SaveOpenScenes();
EditorSceneManager.RestoreSceneManagerSetup(sceneManagerSetup);
}