# ContainsVariant

> Check if the specified ShaderVariantCollection.ShaderVariant exists in the collection.

## Definition

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

## ContainsVariant(Shader, PassIdentifier, LocalKeyword\[])

Check if the specified [ShaderVariantCollection.ShaderVariant](/engine/6000.5/script-reference/unityengine/shadervariantcollection/shadervariant.md) exists in the collection.

```csharp
public bool ContainsVariant(Shader shader, PassIdentifier passId, LocalKeyword[] keywords)
```

### Parameters

**** (\[Shader]\(/engine/6000.5/script-reference/unityengine/shader)): Shader used in the variant.**** (\[PassIdentifier]\(/engine/6000.5/script-reference/unityengine/rendering/passidentifier)): PassIdentifier used in the variant.**** (\[LocalKeyword\[]]\(/engine/6000.5/script-reference/unityengine/rendering/localkeyword)): [LocalKeyword](/engine/6000.5/script-reference/unityengine/rendering/localkeyword.md) array of keywords used in the variant.

### Returns

| Type                                                          | Description                                            |
| ------------------------------------------------------------- | ------------------------------------------------------ |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if variant exists in collection, false otherwise. |

### Remarks

If only the `material` is provided, then this function will check for a shader variant using the set of [Material.enabledKeywords](/engine/6000.5/script-reference/unityengine/material/enabledkeywords.md) combined with the global shader keywords that are **currently enabled** in the active context, unless explicitly provided via `globalKeywords`.

Additional Resources: [GraphicsStateCollection.AddVariant](/engine/6000.5/script-reference/unityengine/rendering/graphicsstatecollection/addvariant.md), [GraphicsStateCollection.RemoveVariant](/engine/6000.5/script-reference/unityengine/rendering/graphicsstatecollection/removevariant.md).

## ContainsVariant(Material, PassIdentifier)

Check if the specified [ShaderVariantCollection.ShaderVariant](/engine/6000.5/script-reference/unityengine/shadervariantcollection/shadervariant.md) exists in the collection.

```csharp
public bool ContainsVariant(Material mat, PassIdentifier passId)
```

### Parameters

**** (\[Material]\(/engine/6000.5/script-reference/unityengine/material)): **** (\[PassIdentifier]\(/engine/6000.5/script-reference/unityengine/rendering/passidentifier)): PassIdentifier used in the variant.

### Returns

| Type                                                          | Description                                            |
| ------------------------------------------------------------- | ------------------------------------------------------ |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if variant exists in collection, false otherwise. |

### Remarks

If only the `material` is provided, then this function will check for a shader variant using the set of [Material.enabledKeywords](/engine/6000.5/script-reference/unityengine/material/enabledkeywords.md) combined with the global shader keywords that are **currently enabled** in the active context, unless explicitly provided via `globalKeywords`.

Additional Resources: [GraphicsStateCollection.AddVariant](/engine/6000.5/script-reference/unityengine/rendering/graphicsstatecollection/addvariant.md), [GraphicsStateCollection.RemoveVariant](/engine/6000.5/script-reference/unityengine/rendering/graphicsstatecollection/removevariant.md).

## ContainsVariant(Material, PassIdentifier, GlobalKeyword\[])

Check if the specified [ShaderVariantCollection.ShaderVariant](/engine/6000.5/script-reference/unityengine/shadervariantcollection/shadervariant.md) exists in the collection.

```csharp
public bool ContainsVariant(Material mat, PassIdentifier passId, GlobalKeyword[] globalKeywords)
```

### Parameters

**** (\[Material]\(/engine/6000.5/script-reference/unityengine/material)): **** (\[PassIdentifier]\(/engine/6000.5/script-reference/unityengine/rendering/passidentifier)): PassIdentifier used in the variant.**** (\[GlobalKeyword\[]]\(/engine/6000.5/script-reference/unityengine/rendering/globalkeyword)): [GlobalKeyword](/engine/6000.5/script-reference/unityengine/rendering/globalkeyword.md) array of global keywords used in the variant.

### Returns

| Type                                                          | Description                                            |
| ------------------------------------------------------------- | ------------------------------------------------------ |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if variant exists in collection, false otherwise. |

### Remarks

If only the `material` is provided, then this function will check for a shader variant using the set of [Material.enabledKeywords](/engine/6000.5/script-reference/unityengine/material/enabledkeywords.md) combined with the global shader keywords that are **currently enabled** in the active context, unless explicitly provided via `globalKeywords`.

Additional Resources: [GraphicsStateCollection.AddVariant](/engine/6000.5/script-reference/unityengine/rendering/graphicsstatecollection/addvariant.md), [GraphicsStateCollection.RemoveVariant](/engine/6000.5/script-reference/unityengine/rendering/graphicsstatecollection/removevariant.md).
