Quick Start
1. Adding An Instance
Go to Magic Lightmap Switcher âžž Examples âžž Scenes folder and open the Quick Start scene.

Go to the editor menu Tools âžž Magic Tools âžž Magic Lightmap Switcher âžž MLS Manager
After selecting a menu item, the dockable MLS Manager window will open. You can move it to a place convenient for you.

Click the "Add Instance" button, the Magic Lightmap Switcher object will be added to the scene in the "Magic Tools" group of objects (if there is no such object on the scene, it will be automatically created)
The manager window will look like this.

2. Creating Presets
Now you can prepare some lighting presets for your scene and save it. Click the "Create New..." button to create a new preset. The preset manager window will open automatically.

Click the "Start Recording" button. Then select the light source on the scene (Directional LIght) and change the Transform component to it.

Change the Rotation values ​​like this: X: 20; Y: -30; Z: 0
After the MLS captures the changes, a special component-marker will be added - the MLS Tracked Object. This component displays the GUID of the object, a list of tracked components on the object, and options for blending in runtime.


Now press the "Duplicate And Edit" button - the preset will be duplicated. The recording of the duplicated preset will be started automatically.
Change the Rotation values ​​like this: X: 20; Y: -90; Z: 0
Repeat the action and change the values ​​like this: X: 20; Y: -150; Z: 0
Now you have three presets, you can switch between them and edit them.

3. Baking
Change the "Storing Mode" to "Queue", check the "Create Lightmap Scenario" option and click the "Bake and And Store Lightmaps Queue" button. This will start the automatic process of baking and storing the lightmaps for all added (and checked) presets.

When baking is complete, all saved lightmaps will be displayed in the manager window, and the scene will be lit by the first stored lightmap.

4. Testing The Scenario
4.1 Lightmap Switching
You can switch between baked lightmaps. To test this, click one of the "Load" buttons in the "Blendable Lightmaps Queue" (only for Editor).

After completing the setup, you can start switching lightmaps directly in the editor, however, this will not work in play mode, since this requires a call to a special API. You can call this API according to your own rules, however, to simplify the example, a simple script was created that is attached to the "Runtime Switching (0-2)" objects in the "Game Logic" object.

This script calls the Switching API and contains two options - "Lighting Scenario" and "Lightmap Index". Using the Unity selection window, select the appropriate scenario for script. The name of the scenario created for a particular scene begins with the name of this scene, for example, for Quick Start scene, this will be the scenario Quick Start_New Lightmap Scenario_0.
Assign a lighting scenario to all three objects.

You can now test switching lighting maps in play mode. Disable the "Runtime Blending" object as it is not configured and go to paly mode.
Move the Cube object along the Z axis. You will see the lightmaps switching.

4.2. Lightmap Blending
To check that everything is working correctly, switch to the Switching/Blending tab in the manager window. The plugin automatically created a default Lightmap Scenario for you and added all saved lightmaps to it.

Move the Global Blend slider. You should see the lighting data blend smoothly in real time.
After completing the setup, you can start switching and blending lightmaps directly in the editor, however, this will not work in play mode, since this requires a call to a special API. You can call this API according to your own rules, however, to simplify the example, a simple script was created that is attached to the "Runtime Blending" object in the "Game Logic" object.

This script calls the Cyclic Blend API and contains two options - "Lighting Scenario" and "Blending Length". Using the Unity selection window, select the appropriate scenario for script. The name of the scenario created for a particular scene begins with the name of this scene, for example, for Quick Start scene, this will be the scenario Quick Start_New Lightmap Scenario_0.

Now you can start playing. Once launched, the script will automatically run.

Last updated