Scenes Workflow

1. Single Scene

The process of working with one scene is quite simple and is mainly described in the "Quick Start" section. The instructions from there will work for most cases.

2. Multi-Scene

Clarifications and caveats

Some problems can arise from the way Unity handles loading of light probes for scenes. At the moment the system is strictly coded to load all light probes for the scene just loaded and completely unload all light probes for the scene from which the load was called. This allows you to maintain some stability during the transition between scenes, but it will not work if you need to load two scenes at once. Such cases cause the indexes in the light probe array to change. There is special code for this that tries to catch situations and align the indexes, but this does not always work, so it is commented out. This is in the MagicLightmapSwitcher.cs file on 1249 line.

In addition, during the preparation of scenes, the editor can go into an endless loop trying to import assets. This is a known Unity issue that was discussed here but never resolved.

2.1 Adding a Master Scene

The structure below is an example and may not match your own.

Go to Magic Lightmap Switcher Examples Scenes Multi-Scene Workflow folder and open the Master Scene

This scene contains only a camera, a simple script to load the scene additively (attached to the "Game Logic" object) and a cube that will act as a player.

The CallAdditiveSceneLoading script calls a special MLS API method SceneManagment.LoadSceneAdditive.

You should always use the SceneManagment.LoadSceneAdditive and SceneManagment.UnloadScene methods to work with multiple scenes and MLS, as this requires certain steps to load properly.

2.2 Adding Target Scenes

Go to Magic Lightmap Switcher Examples Scenes Included Scenes folder and drag Scene A, Scene B, Scene C and Scene D into hierarchy.

To reduce the size of the downloadable package from the asset store, the lightmaps on the scenes are not baked, in addition, this process is part of the process of working with the asset.

2.3 Setting Target Scenes

All scenes you add are preconfigured and contain an instance of the main component.

Unload all scenes except Scene A. Then go to the editor menu Tools Magic Tools Magic Ligtmap Switcher MLS Manager

Make sure the scene is active. (right click on the scene hierarchy name ➞ Set Active Scene)

It is assumed that you have already completed the short tutorial in the "Quick Start" section, so some steps will be skipped below. If you have not studied this section, then please return to it, otherwise some of the steps may not be clear to you.

Go to the manager window, switch the "Storing Mode" option to "Queue" and click the "Bake and And Store Lightmaps Queue" button.

Make sure the Workflow option is set to Mulity Scene. You should always use this mode when working with multiple scenes.

When the baking and storing process is complete, go to the "Runtime Blending" object inspector, it is located in the "Game Logic" object hierarchy.

Assign the Lighting Scenario created for this scene in the "Lighting Scenario" field.

Scene setup complete.

Repeat instructions in step 2.3 for each added scene.

2.4 Playing

When all the scenes are set up, leave only the "Master Scene" loaded and start the play mode.

In this example, triggers are used to load and unload scenes, and its are located in different parts of each scene.

Move the "Player" object, you will see how the scenes change each other and each of its starts its own Lightmap Scenario.

Last updated