---
title: ContainsComputeVariant(ComputeShader, int, LocalKeyword[])
product: Unity Editor
version: '7000.0'
latest_version: '7000.0'
status: This page documents version 7000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/en-us/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/containscomputevariant
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/containscomputevariant.md
last_updated: 2026-11-13
generated_at: 2026-11-18T08:38:18.968Z
locale: en-us
---

# ContainsComputeVariant(ComputeShader, int, LocalKeyword[])

> Checks whether the specified compute shader variant exists in the collection.

## Definition

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

```csharp
public bool ContainsComputeVariant(ComputeShader shader, int kernelIndex, LocalKeyword[] keywords)
```

### Parameters

**** (\[ComputeShader]\(/engine/7000.0/script-reference/unityengine/computeshader)): The [ComputeShader](/engine/7000.0/script-reference/unityengine/computeshader.md) of the variant.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the kernel in `shader`.**** (\[LocalKeyword\[]]\(/engine/7000.0/script-reference/unityengine/rendering/localkeyword)): The [LocalKeyword](/engine/7000.0/script-reference/unityengine/rendering/localkeyword.md) array of the variant. The order of the keywords doesn't matter. Unity ignores keywords that the kernel doesn't declare and keywords that only select a dynamic branch.

### Returns

| Type                                                          | Description                                                                         |
| ------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | Returns `true` if the variant exists in the collection. Otherwise, returns `false`. |

### Remarks

Returns `false` if `shader` is `null`. The comparison uses the same keyword normalization as [GraphicsStateCollection.AddComputeVariant](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/addcomputevariant.md).

Additional Resources: [GraphicsStateCollection.AddComputeVariant](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/addcomputevariant.md), [GraphicsStateCollection.RemoveComputeVariant](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/removecomputevariant.md).

### Examples

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

// Attach this script to a GameObject, then assign a graphics state collection and a compute shader in the Inspector.
public class ContainsComputeVariantExample : MonoBehaviour
{
    public GraphicsStateCollection graphicsStateCollection;
    public ComputeShader computeShader;

    void Start()
    {
        // Uses the CSMain kernel with the keywords currently enabled on the compute shader.
        int kernelIndex = computeShader.FindKernel("CSMain");
        bool contains = graphicsStateCollection.ContainsComputeVariant(computeShader, kernelIndex, computeShader.enabledKeywords);
        Debug.Log(contains ? "The collection contains the compute shader variant." : "The collection doesn't contain the compute shader variant.");
    }
}
```
