# GetReferenceCount(LightProbes)

> Gets the number of times lightProbes has been registered using LightProbes.Append without a corresponding LightProbes.Remove.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public static int GetReferenceCount(LightProbes lightProbes)
```

### Parameters

**** (\[LightProbes]\(/engine/6000.7/script-reference/unityengine/lightprobes)): The `LightProbes` object to query for its reference count.

### Returns

| Type                                                       | Description                                                                                                |
| ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The current reference count. A value greater than `0` means the object is registered for use in rendering. |

### Remarks

The reference count increments with each call to [LightProbes.Append](/engine/6000.7/script-reference/unityengine/lightprobes/append.md) and decrements with each call to [LightProbes.Remove](/engine/6000.7/script-reference/unityengine/lightprobes/remove.md). When it reaches zero, the object is no longer registered for use in rendering. Loading or unloading a scene that contains light probes has the same effect, because Unity calls [LightProbes.Append](/engine/6000.7/script-reference/unityengine/lightprobes/append.md) and [LightProbes.Remove](/engine/6000.7/script-reference/unityengine/lightprobes/remove.md) automatically for the `LightProbes` objects belonging to that scene.

Additional Resources: [LightProbes.Append](/engine/6000.7/script-reference/unityengine/lightprobes/append.md), [LightProbes.Remove](/engine/6000.7/script-reference/unityengine/lightprobes/remove.md), [LightProbes.IsActive](/engine/6000.7/script-reference/unityengine/lightprobes/isactive.md).

### Examples

```csharp
// Attach this script to a GameObject, then enter Play mode.
// The script appends a LightProbes object twice, then removes it, logging the
// reference count at each step so you can observe how it increments and decrements.

using UnityEngine;
using UnityEngine.Rendering;

public class GetReferenceCountExample : MonoBehaviour
{
    void Start()
    {
        LightProbes probes = new LightProbes(1);
        probes.SetPositionsSelf(new Vector3[] { transform.position }, false);
        probes.SetSHCoefficientsSelf(new SphericalHarmonicsL2[1]);

        LightProbes.Append(probes);
        LightProbes.Append(probes);
        Debug.Log($"After two Append calls: {LightProbes.GetReferenceCount(probes)}");

        LightProbes.Remove(probes);
        Debug.Log($"After one Remove call: {LightProbes.GetReferenceCount(probes)}");

        LightProbes.Remove(probes);
        Debug.Log($"After two Remove calls: {LightProbes.GetReferenceCount(probes)}");

        LightProbes.Tetrahedralize();
    }
}
```
