You might need to move Light ProbesLight probes store information about how light passes through space in your scene. A collection of light probes arranged within a given space can improve lighting on moving objects and static LOD scenery within that space. More info
See in Glossary at runtime. For example, if you create a world by loading multiple scenes additively and then move each sceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary to a different position, you need to move the Light Probes with their related scene objects.
You can use the LightProbes API to move Light Probes at runtime. You can’t move Light Probes by updating the Transform componentA Transform component determines the Position, Rotation, and Scale of each object in the scene. Every GameObject has a Transform. More info
See in Glossary of the Light Probe GroupA component that enables you to add Light Probes to GameObjects in your scene. More info
See in Glossary object, because the Transform only affects baking.
When you move Light Probes using the API, only the positions change. The baked data stored in the Light Probes stays the same.
Follow these steps:
Scene
object) will use this cloned data from now on.If you baked the scene together with other scenes that contain Light Probes, the returned data contains Light Probes from all the baked scenes. Refer to Light Probes and Scene loading for more information about using Light Probes in multiple scenes.
The Tetrahedralize
APIs can take a long time. If you move multiple Light Probes, it’s best to tetrahedralize once at the end.
You can use the LightProbes.GetSharedLightProbesForScene API instead if you need to read the positions of the Light Probes in a scene, but not move them.
The following code moves the Light Probes in the current scene to a new position each frame.
Attach the script to any object in a scene. When you run the project, select any object that uses Light Probes so you can see the probes move. The Light Probe Group object doesn’t move.
using UnityEngine;
using UnityEngine.SceneManagement;
public class LoadSingleSceneAndMoveProbes : MonoBehaviour
{
void Update()
{
// Get a copy of the Light Probes in the current scene
LightProbes lightProbes = LightProbes.GetInstantiatedLightProbesForScene(SceneManager.GetActiveScene());
// Get the Light Probe positions
Vector3[] positions = lightProbes.GetPositionsSelf();
// Update the positions
for (int i = 0; i < positions.Length; i++)
{
positions[i].x = positions[i].x + 0.01f;
}
// Copy the new positions back to the Light Probes
lightProbes.SetPositionsSelf(positions, true);
// Tetrahedralize to update the data in the LightProbes object of the scene.
LightProbes.Tetrahedralize();
}
}
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.