# CompileVariant

> Compiles a shader variant for this shader pass and returns its bytecode and resource layout.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.5/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

## CompileVariant(ShaderType, string\[], ShaderCompilerPlatform, BuildTarget)

Compiles a shader variant for this shader pass and returns its bytecode and resource layout.

```csharp
public ShaderData.VariantCompileInfo CompileVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget)
```

### Parameters

**** (\[ShaderType]\(/engine/6000.5/script-reference/unityeditor/rendering/shadertype)): The shader type within this pass to compile. (e.g. Vertex, Fragment, etc.)  Some platforms (OpenGLCore, GLES3x, Switch and Vulkan) include all stages within the Vertex shader type.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): The keywords to use during the compilation.**** (\[ShaderCompilerPlatform]\(/engine/6000.5/script-reference/unityeditor/rendering/shadercompilerplatform)): The shader compiler platform to compile for.**** (\[BuildTarget]\(/engine/6000.5/script-reference/unityeditor/buildtarget)): The build target to compile for.

### Returns

| Type                                                                                               | Description                                                                                                                                                                                                                          |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [VariantCompileInfo](/engine/6000.5/script-reference/unityeditor/shaderdata/variantcompileinfo.md) | The compiled variant result, including resource layout information and bytecode. If the pass doesn't include the requested program, or if the pass is not the correct type, this function still succeeds but returns empty bytecode. |

## CompileVariant(ShaderType, string\[], ShaderCompilerPlatform, BuildTarget, bool)

Compiles a shader variant for this shader pass and returns its bytecode and resource layout.

```csharp
public ShaderData.VariantCompileInfo CompileVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, bool forExternalTool)
```

### Parameters

**** (\[ShaderType]\(/engine/6000.5/script-reference/unityeditor/rendering/shadertype)): The shader type within this pass to compile. (e.g. Vertex, Fragment, etc.)  Some platforms (OpenGLCore, GLES3x, Switch and Vulkan) include all stages within the Vertex shader type.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): The keywords to use during the compilation.**** (\[ShaderCompilerPlatform]\(/engine/6000.5/script-reference/unityeditor/rendering/shadercompilerplatform)): The shader compiler platform to compile for.**** (\[BuildTarget]\(/engine/6000.5/script-reference/unityeditor/buildtarget)): The build target to compile for.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Indicates whether to prepare the bytecode for Unity or to use with external tools.

### Returns

| Type                                                                                               | Description                                                                                                                                                                                                                          |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [VariantCompileInfo](/engine/6000.5/script-reference/unityeditor/shaderdata/variantcompileinfo.md) | The compiled variant result, including resource layout information and bytecode. If the pass doesn't include the requested program, or if the pass is not the correct type, this function still succeeds but returns empty bytecode. |

## CompileVariant(ShaderType, string\[], ShaderCompilerPlatform, BuildTarget, GraphicsTier)

Compiles a shader variant for this shader pass and returns its bytecode and resource layout.

```csharp
public ShaderData.VariantCompileInfo CompileVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, GraphicsTier tier)
```

### Parameters

**** (\[ShaderType]\(/engine/6000.5/script-reference/unityeditor/rendering/shadertype)): The shader type within this pass to compile. (e.g. Vertex, Fragment, etc.)  Some platforms (OpenGLCore, GLES3x, Switch and Vulkan) include all stages within the Vertex shader type.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): The keywords to use during the compilation.**** (\[ShaderCompilerPlatform]\(/engine/6000.5/script-reference/unityeditor/rendering/shadercompilerplatform)): The shader compiler platform to compile for.**** (\[BuildTarget]\(/engine/6000.5/script-reference/unityeditor/buildtarget)): The build target to compile for.**** (\[GraphicsTier]\(/engine/6000.5/script-reference/unityengine/rendering/graphicstier)): An optional graphics tier.

### Returns

| Type                                                                                               | Description                                                                                                                                                                                                                          |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [VariantCompileInfo](/engine/6000.5/script-reference/unityeditor/shaderdata/variantcompileinfo.md) | The compiled variant result, including resource layout information and bytecode. If the pass doesn't include the requested program, or if the pass is not the correct type, this function still succeeds but returns empty bytecode. |

## CompileVariant(ShaderType, string\[], ShaderCompilerPlatform, BuildTarget, GraphicsTier, bool)

Compiles a shader variant for this shader pass and returns its bytecode and resource layout.

```csharp
public ShaderData.VariantCompileInfo CompileVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, GraphicsTier tier, bool forExternalTool)
```

### Parameters

**** (\[ShaderType]\(/engine/6000.5/script-reference/unityeditor/rendering/shadertype)): The shader type within this pass to compile. (e.g. Vertex, Fragment, etc.)  Some platforms (OpenGLCore, GLES3x, Switch and Vulkan) include all stages within the Vertex shader type.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): The keywords to use during the compilation.**** (\[ShaderCompilerPlatform]\(/engine/6000.5/script-reference/unityeditor/rendering/shadercompilerplatform)): The shader compiler platform to compile for.**** (\[BuildTarget]\(/engine/6000.5/script-reference/unityeditor/buildtarget)): The build target to compile for.**** (\[GraphicsTier]\(/engine/6000.5/script-reference/unityengine/rendering/graphicstier)): An optional graphics tier.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Indicates whether to prepare the bytecode for Unity or to use with external tools.

### Returns

| Type                                                                                               | Description                                                                                                                                                                                                                          |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [VariantCompileInfo](/engine/6000.5/script-reference/unityeditor/shaderdata/variantcompileinfo.md) | The compiled variant result, including resource layout information and bytecode. If the pass doesn't include the requested program, or if the pass is not the correct type, this function still succeeds but returns empty bytecode. |

## CompileVariant(ShaderType, string\[], ShaderCompilerPlatform, BuildTarget, BuiltinShaderDefine\[])

Compiles a shader variant for this shader pass and returns its bytecode and resource layout.

```csharp
public ShaderData.VariantCompileInfo CompileVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, BuiltinShaderDefine[] platformKeywords)
```

### Parameters

**** (\[ShaderType]\(/engine/6000.5/script-reference/unityeditor/rendering/shadertype)): The shader type within this pass to compile. (e.g. Vertex, Fragment, etc.)  Some platforms (OpenGLCore, GLES3x, Switch and Vulkan) include all stages within the Vertex shader type.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): The keywords to use during the compilation.**** (\[ShaderCompilerPlatform]\(/engine/6000.5/script-reference/unityeditor/rendering/shadercompilerplatform)): The shader compiler platform to compile for.**** (\[BuildTarget]\(/engine/6000.5/script-reference/unityeditor/buildtarget)): The build target to compile for.**** (\[BuiltinShaderDefine\[]]\(/engine/6000.5/script-reference/unityengine/rendering/builtinshaderdefine)): An optional set of platform keywords. If you do not provide any, Unity uses the default keywords for the given platform, target, and tier.

### Returns

| Type                                                                                               | Description                                                                                                                                                                                                                          |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [VariantCompileInfo](/engine/6000.5/script-reference/unityeditor/shaderdata/variantcompileinfo.md) | The compiled variant result, including resource layout information and bytecode. If the pass doesn't include the requested program, or if the pass is not the correct type, this function still succeeds but returns empty bytecode. |

## CompileVariant(ShaderType, string\[], ShaderCompilerPlatform, BuildTarget, BuiltinShaderDefine\[], bool)

Compiles a shader variant for this shader pass and returns its bytecode and resource layout.

```csharp
public ShaderData.VariantCompileInfo CompileVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, BuiltinShaderDefine[] platformKeywords, bool forExternalTool)
```

### Parameters

**** (\[ShaderType]\(/engine/6000.5/script-reference/unityeditor/rendering/shadertype)): The shader type within this pass to compile. (e.g. Vertex, Fragment, etc.)  Some platforms (OpenGLCore, GLES3x, Switch and Vulkan) include all stages within the Vertex shader type.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): The keywords to use during the compilation.**** (\[ShaderCompilerPlatform]\(/engine/6000.5/script-reference/unityeditor/rendering/shadercompilerplatform)): The shader compiler platform to compile for.**** (\[BuildTarget]\(/engine/6000.5/script-reference/unityeditor/buildtarget)): The build target to compile for.**** (\[BuiltinShaderDefine\[]]\(/engine/6000.5/script-reference/unityengine/rendering/builtinshaderdefine)): An optional set of platform keywords. If you do not provide any, Unity uses the default keywords for the given platform, target, and tier.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Indicates whether to prepare the bytecode for Unity or to use with external tools.

### Returns

| Type                                                                                               | Description                                                                                                                                                                                                                          |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [VariantCompileInfo](/engine/6000.5/script-reference/unityeditor/shaderdata/variantcompileinfo.md) | The compiled variant result, including resource layout information and bytecode. If the pass doesn't include the requested program, or if the pass is not the correct type, this function still succeeds but returns empty bytecode. |

## CompileVariant(ShaderType, string\[], ShaderCompilerPlatform, BuildTarget, BuiltinShaderDefine\[], GraphicsTier)

Compiles a shader variant for this shader pass and returns its bytecode and resource layout.

```csharp
public ShaderData.VariantCompileInfo CompileVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, BuiltinShaderDefine[] platformKeywords, GraphicsTier tier)
```

### Parameters

**** (\[ShaderType]\(/engine/6000.5/script-reference/unityeditor/rendering/shadertype)): The shader type within this pass to compile. (e.g. Vertex, Fragment, etc.)  Some platforms (OpenGLCore, GLES3x, Switch and Vulkan) include all stages within the Vertex shader type.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): The keywords to use during the compilation.**** (\[ShaderCompilerPlatform]\(/engine/6000.5/script-reference/unityeditor/rendering/shadercompilerplatform)): The shader compiler platform to compile for.**** (\[BuildTarget]\(/engine/6000.5/script-reference/unityeditor/buildtarget)): The build target to compile for.**** (\[BuiltinShaderDefine\[]]\(/engine/6000.5/script-reference/unityengine/rendering/builtinshaderdefine)): An optional set of platform keywords. If you do not provide any, Unity uses the default keywords for the given platform, target, and tier.**** (\[GraphicsTier]\(/engine/6000.5/script-reference/unityengine/rendering/graphicstier)): An optional graphics tier.

### Returns

| Type                                                                                               | Description                                                                                                                                                                                                                          |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [VariantCompileInfo](/engine/6000.5/script-reference/unityeditor/shaderdata/variantcompileinfo.md) | The compiled variant result, including resource layout information and bytecode. If the pass doesn't include the requested program, or if the pass is not the correct type, this function still succeeds but returns empty bytecode. |

## CompileVariant(ShaderType, string\[], ShaderCompilerPlatform, BuildTarget, BuiltinShaderDefine\[], GraphicsTier, bool)

Compiles a shader variant for this shader pass and returns its bytecode and resource layout.

```csharp
public ShaderData.VariantCompileInfo CompileVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, BuiltinShaderDefine[] platformKeywords, GraphicsTier tier, bool forExternalTool)
```

### Parameters

**** (\[ShaderType]\(/engine/6000.5/script-reference/unityeditor/rendering/shadertype)): The shader type within this pass to compile. (e.g. Vertex, Fragment, etc.)  Some platforms (OpenGLCore, GLES3x, Switch and Vulkan) include all stages within the Vertex shader type.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): The keywords to use during the compilation.**** (\[ShaderCompilerPlatform]\(/engine/6000.5/script-reference/unityeditor/rendering/shadercompilerplatform)): The shader compiler platform to compile for.**** (\[BuildTarget]\(/engine/6000.5/script-reference/unityeditor/buildtarget)): The build target to compile for.**** (\[BuiltinShaderDefine\[]]\(/engine/6000.5/script-reference/unityengine/rendering/builtinshaderdefine)): An optional set of platform keywords. If you do not provide any, Unity uses the default keywords for the given platform, target, and tier.**** (\[GraphicsTier]\(/engine/6000.5/script-reference/unityengine/rendering/graphicstier)): An optional graphics tier.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Indicates whether to prepare the bytecode for Unity or to use with external tools.

### Returns

| Type                                                                                               | Description                                                                                                                                                                                                                          |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [VariantCompileInfo](/engine/6000.5/script-reference/unityeditor/shaderdata/variantcompileinfo.md) | The compiled variant result, including resource layout information and bytecode. If the pass doesn't include the requested program, or if the pass is not the correct type, this function still succeeds but returns empty bytecode. |
