Multi-scene baking in 5.2

Hi,

One of the release notes for 5.2 says:

  • Multi Scene Lighting baking. Lightmapping.BakeMultipleScenes(string[ ] scenes);

  • Lets you bake lightmaps, reflection probes and realtime lightmaps for multiple scenes which together, which can be loaded additively. Data is automatically split on bake per scene

Can someone explain what this means exactly and how it works? Would this allow me to somehow remake all the scenes in my game using a new setting (or even the current setting) one after the other? I’m facing a bug with GI in 5.2 right now that remaking the scene seems to fix. However, opening and baking each scene is tedious as there are almost a hundred scenes in the project. Is there now something I can do that will go through each scene and perform the light baking? This would be great as I could then have it run overnight and just have it do one scene after another.

If not, is there any way to do what I described?

It’s a bit of a hack but Lightmapping.BakeMultipleScenes() should support what you want to do. Just have a for loop where you iterate over all of your scenes and call that function. However, I think that’s the same thing as opening the scene, calling Lightmapping.Bake(), and then saving the scene.

Thanks for the advise. I put the following code into an editor script (in a button):

string[] paths = new string[EditorBuildSettings.scenes.Length];


            for (int i = 0; i < paths.Length; i++)
            {
                paths[i] = EditorBuildSettings.scenes[i].path;

            }

            Lightmapping.BakeMultipleScenes(paths);

It doesn’t work though … it says “No duplication of scenes is allowed”. Any idea what the issue might be?

Presumably the same scene appears multiple times in your build settings and the bake function doesn’t like it.

Thank I managed to do it w cod that jus opened opened scene and performed the bake and then opened the next one.