Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

LightProbes.Remove

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static void Remove(LightProbes lightProbes);

Parameters

Parameter Description
lightProbes The LightProbes object to unregister.

Description

Unregisters a LightProbes object from the light probe system, removing it from rendering.

After calling Remove, call LightProbes.Tetrahedralize or LightProbes.TetrahedralizeAsync to apply the changes.

Each call to Remove decrements the internal reference count for lightProbes. When the count reaches zero, the object's probes are no longer registered for use in rendering.

Remove is called automatically for LightProbes objects belonging to a scene when that scene is unloaded.

Additional resources: LightProbes.Append, LightProbes.IsActive, LightProbes.GetReferenceCount, LightProbes.needsRetetrahedralization.

// Attach this script to a GameObject, then enter Play mode.
// The script spawns a cloud of randomly placed light probes,
// which affects rendering immediately.
// Destroying the GameObject removes the probes again.

using UnityEngine; using UnityEngine.Rendering;

public class SpawnLightProbes : MonoBehaviour { public int count = 100; public float radius = 5;

LightProbes probes;

void Start() { probes = new LightProbes(count); Vector3[] positions = new Vector3[count]; SphericalHarmonicsL2[] coefficients = new SphericalHarmonicsL2[count]; for (int i = 0; i < count; i++) { positions[i] = transform.position + Random.insideUnitSphere * radius; SphericalHarmonicsL2 sh = new SphericalHarmonicsL2(); sh.AddAmbientLight(Color.Lerp(Color.red, Color.blue, Random.value)); coefficients[i] = sh; } probes.SetPositionsSelf(positions, false); probes.SetSHCoefficientsSelf(coefficients); LightProbes.Append(probes); LightProbes.Tetrahedralize(); }

void OnDestroy() { LightProbes.Remove(probes); LightProbes.Tetrahedralize(); } }