For the complete documentation index, see llms.txt. This page is also available as Markdown.

Quick Start

Before proceeding with the next steps, please read the instructions in the "General Settings" section. This is a necessary step before using the plugin.

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.

Scene must contain an instance of the Magic Lightmap Switcher. This is necessary for the plugin to process scene objects.

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.

You can name the presets whatever you like. These names will then be used to display the saved lightmaps.

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

Please note that MLS only tracks changes, so in order for MLS to start tracking anything, you must change something in the component.

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.

By default, new tracked objects are not marked as "Blendable". You can determine for yourself whether you need MLS to interpolate captured fields and component properties in runtime. In this case, you need to mark the object as "Blendable". This can be done directly on the MLS Tracked Object component or in the preset.

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

Lightmap Scenario will be created automatically only if you have checked the "Create Lightmap Scenario" option, if the option is not checked, then you need to do it manually.

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