# BeginTrace()

> Start tracing shader variants and graphics states encountered at runtime.

## Definition

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

```csharp
public bool BeginTrace()
```

### Returns

| Type                                                          | Description                                            |
| ------------------------------------------------------------- | ------------------------------------------------------ |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if tracing successfully started, false otherwise. |

### Remarks

The [GraphicsStateCollection.graphicsDeviceType](/engine/6000.5/script-reference/unityengine/rendering/graphicsstatecollection/graphicsdevicetype.md), [GraphicsStateCollection.qualityLevelName](/engine/6000.5/script-reference/unityengine/rendering/graphicsstatecollection/qualitylevelname.md), and [GraphicsStateCollection.runtimePlatform](/engine/6000.5/script-reference/unityengine/rendering/graphicsstatecollection/runtimeplatform.md) for this collection are set when tracing begins.

Tracing cannot begin if any collection is already currently tracing.

```csharp
using UnityEngine;
using UnityEngine.Rendering;

public class BeginTraceExample : MonoBehaviour
{
    public GraphicsStateCollection graphicsStateCollection;

    void Start()
    {
        graphicsStateCollection = new GraphicsStateCollection();
        graphicsStateCollection.BeginTrace();
    }

    void OnDestroy()
    {
        graphicsStateCollection.EndTrace();
    }
}
```

Additional Resources: [GraphicsStateCollection.EndTrace](/engine/6000.5/script-reference/unityengine/rendering/graphicsstatecollection/endtrace.md), [GraphicsStateCollection.isTracing](/engine/6000.5/script-reference/unityengine/rendering/graphicsstatecollection/istracing.md).
