# GraphicsStateCollection

> Collection of shader variants and associated graphics states.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine.Rendering](/engine/6000.7/script-reference/unityengine/rendering.md)
* **Assembly:** UnityEngine.CoreModule
* **Inherits from:** [Object](/engine/6000.7/script-reference/unityengine/object.md)

```csharp
public sealed class GraphicsStateCollection : Object
```

## Remarks

Use graphics state collections to record shader variants and graphics states encountered at runtime and prewarm shader variants.

Each shader variant in the collection may have one or more associated graphics states. Each permutation of a shader variant and a graphics state will result in a single GPU representation of the shader being created by Unity.

`GraphicsStateCollection` generally replaces the [ShaderVariantCollection](/engine/6000.7/script-reference/unityengine/shadervariantcollection.md) class for prewarming shader variants. On legacy graphics APIs that do not support prewarming graphics states, [GraphicsStateCollection.WarmUp](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/warmup.md) will fallback to using [ShaderVariantCollection.WarmUp](/engine/6000.7/script-reference/unityengine/shadervariantcollection/warmup.md).

## Examples

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

public class GraphicsStateCollectionTracing : MonoBehaviour
{
    public GraphicsStateCollection graphicsStateCollection;

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

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

## Constructors

| Constructor                                                                                                                                                       | Description                                                                   |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| [GraphicsStateCollection()](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/ctor.md#graphicsstatecollection\(\))                    | Create a GraphicsStateCollection populated with contents of a file, or empty. |
| [GraphicsStateCollection(System.String)](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/ctor.md#graphicsstatecollection\(string\)) | Create a GraphicsStateCollection populated with contents of a file, or empty. |

## Properties

| Property                                                                                                                            | Description                                                                                                                                                                                                                                             |
| ----------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [cacheMissCollection](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/cachemisscollection.md)         | A separate `GraphicsStateCollection` that stores shader variants and graphics states that were not in this collection during [GraphicsStateCollection.WarmUp](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/warmup.md). |
| [completedWarmupCount](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/completedwarmupcount.md)       | The number of shader variant state permutations that have been warmed up.                                                                                                                                                                               |
| [graphicsDeviceType](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/graphicsdevicetype.md)           | The graphics device API type the collection is intended to be used with.                                                                                                                                                                                |
| [isTracing](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/istracing.md)                             | Flag indicating if the collection is actively tracing shader variants and graphics states.                                                                                                                                                              |
| [isTracingCacheMisses](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/istracingcachemisses.md)       | Flag indicating if the collection is actively tracing cache misses into [GraphicsStateCollection.cacheMissCollection](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/cachemisscollection.md).                            |
| [isWarmedUp](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/iswarmedup.md)                           | Flag indicating if the collection is completely warmed up.                                                                                                                                                                                              |
| [qualityLevelName](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/qualitylevelname.md)               | The quality level the collection is intended to be used with.                                                                                                                                                                                           |
| [runtimePlatform](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/runtimeplatform.md)                 | The platform that the collection is intended to be used with.                                                                                                                                                                                           |
| [totalGraphicsStateCount](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/totalgraphicsstatecount.md) | The total number of graphics states across all shader variants in the collection.                                                                                                                                                                       |
| [variantCount](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/variantcount.md)                       | The number of shader variants contained in this collection.                                                                                                                                                                                             |
| [version](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/version.md)                                 | The current version of the collection.                                                                                                                                                                                                                  |

## Methods

| Method                                                                                                                                              | Description                                                                                                                                                                                            |
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [AddGraphicsStateForVariant](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/addgraphicsstateforvariant.md)           | Adds a new graphics state associated with a shader variant.                                                                                                                                            |
| [AddGraphicsStates](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/addgraphicsstates.md)                             | Generates and adds new graphics states to the collection from arrays of assets.                                                                                                                        |
| [AddGraphicsStatesFromReference](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/addgraphicsstatesfromreference.md)   | Generates and adds new graphics states from arrays of assets, using a reference graphics state to initialize unspecified values.                                                                       |
| [AddVariant](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/addvariant.md)                                           | Adds a new shader variant to the collection.                                                                                                                                                           |
| [AddVariants](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/addvariants.md)                                         | Adds one or more new shader variants to the collection.                                                                                                                                                |
| [Append](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/append.md)                                                   | Adds all new graphics states and shader variants from the given `collection` to this collection.                                                                                                       |
| [BeginTrace](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/begintrace.md)                                           | Start tracing shader variants and graphics states encountered at runtime.                                                                                                                              |
| [ClearVariants](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/clearvariants.md)                                     | Clears all shader variants and associated graphics states from the collection.                                                                                                                         |
| [ContainsVariant](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/containsvariant.md)                                 | Check if the specified [ShaderVariantCollection.ShaderVariant](/engine/6000.7/script-reference/unityengine/shadervariantcollection/shadervariant.md) exists in the collection.                         |
| [CopyGraphicsStatesForVariant](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/copygraphicsstatesforvariant.md)       | Copy all the graphics states from the source variant to the destination variant.                                                                                                                       |
| [EndTrace](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/endtrace.md)                                               | Stop tracing shader variants and graphics states encountered at runtime.                                                                                                                               |
| [EraseCacheMissCollection](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/erasecachemisscollection.md)               | Erase the [GraphicsStateCollection.cacheMissCollection](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/cachemisscollection.md) and all its entries, setting it to null. |
| [GetGraphicsStateCountForVariant](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/getgraphicsstatecountforvariant.md) | Get the number of graphics states associated with an input shader variant.                                                                                                                             |
| [GetGraphicsStatesForVariant](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/getgraphicsstatesforvariant.md)         | Populate given list with graphics states associated with an input shader variant.                                                                                                                      |
| [GetVariants](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/getvariants.md)                                         | Populate given list with shader variants contained in the collection.                                                                                                                                  |
| [LoadFromFile](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/loadfromfile.md)                                       | Load the GraphicsStateCollection at the given path.                                                                                                                                                    |
| [LoadFromJson](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/loadfromjson.md)                                       | Load a GraphicsStateCollection from the provided JSON-formatted string.                                                                                                                                |
| [RemoveGraphicsStatesForVariant](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/removegraphicsstatesforvariant.md)   | Remove all associated graphics states from an input shader variant.                                                                                                                                    |
| [RemoveVariant](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/removevariant.md)                                     | Remove [ShaderVariantCollection.ShaderVariant](/engine/6000.7/script-reference/unityengine/shadervariantcollection/shadervariant.md) and associated graphics states from collection.                   |
| [SaveToFile](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/savetofile.md)                                           | Save GraphicsStateCollection to disk.                                                                                                                                                                  |
| [SendToEditor](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/sendtoeditor.md)                                       | Send GraphicsStateCollection to the Editor using PlayerConnection.                                                                                                                                     |
| [WarmUp](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/warmup.md)                                                   | Prewarms all shader variants in this collection using associated graphics states.                                                                                                                      |
| [WarmUpProgressively](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/warmupprogressively.md)                         | Prewarms the given number of shader variant state permutations using associated graphics states.                                                                                                       |

## Structs

| Struct                                                                                                                                  | Description                                                                                                                                                        |
| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [GraphicsStateCollection.GraphicsState](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/graphicsstate.md) | A graphics state identifies a specific rendering configuration.                                                                                                    |
| [GraphicsStateCollection.ShaderVariant](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/shadervariant.md) | Identifies a specific variant of a shader stored in a [GraphicsStateCollection](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection.md). |

## Inheritance

**Inherited Members:**

* [Object.GetEntityId()](/engine/6000.7/script-reference/unityengine/object/getentityid.md)
* [Object.GetHashCode()](/engine/6000.7/script-reference/unityengine/object/gethashcode.md)
* [Object.InstantiateAsync\<T>(T)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, InstantiateParameters, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, InstantiateParameters, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, InstantiateParameters, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.Instantiate(Object, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion\))
* [Object.Instantiate(Object, Vector3, Quaternion, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion-transform\))
* [Object.Instantiate(Object)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object\))
* [Object.Instantiate(Object, Scene)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object-scene\))
* [Object.Instantiate\<T>(T, InstantiateParameters)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, InstantiateParameters)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate(Object, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform\))
* [Object.Instantiate(Object, Transform, bool)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform-bool\))
* [Object.Instantiate\<T>(T)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform, bool)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Destroy(Object, float)](/engine/6000.7/script-reference/unityengine/object/destroy.md)
* [Object.DestroyImmediate(Object, bool)](/engine/6000.7/script-reference/unityengine/object/destroyimmediate.md)
* [Object.FindObjectsByType(Type)](/engine/6000.7/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type\))
* [Object.FindObjectsByType(Type, FindObjectsInactive)](/engine/6000.7/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type-findobjectsinactive\))
* [Object.DontDestroyOnLoad(Object)](/engine/6000.7/script-reference/unityengine/object/dontdestroyonload.md)
* [Object.FindAnyObjectByType\<T>()](/engine/6000.7/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(\))
* [Object.FindAnyObjectByType\<T>(FindObjectsInactive)](/engine/6000.7/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(findobjectsinactive\))
* [Object.FindObjectsByType\<T>()](/engine/6000.7/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(\))
* [Object.FindObjectsByType\<T>(FindObjectsInactive)](/engine/6000.7/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(findobjectsinactive\))
* [Object.FindAnyObjectByType(Type)](/engine/6000.7/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type\))
* [Object.FindAnyObjectByType(Type, FindObjectsInactive)](/engine/6000.7/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type-findobjectsinactive\))
* [Object.ToString()](/engine/6000.7/script-reference/unityengine/object/tostring.md)
* [Object.name](/engine/6000.7/script-reference/unityengine/object/name.md)
* [Object.hideFlags](/engine/6000.7/script-reference/unityengine/object/hideflags.md)

### Operators

| Operator                                                                           | Description                                                             |
| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [operator ==](/engine/6000.7/script-reference/unityengine/object/op-equality.md)   | Compares two object references to see if they refer to the same object. |
| [bool](/engine/6000.7/script-reference/unityengine/object/op-implicit.md)          | Determines whether the object exists.                                   |
| [operator !=](/engine/6000.7/script-reference/unityengine/object/op-inequality.md) | Compares if two objects refer to a different object.                    |
