Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


CompileVariant

Compiles a shader variant for this shader pass and returns its bytecode and resource layout.
Read time 6 minutesLast updated 10 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor

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

Compiles a shader variant for this shader pass and returns its bytecode and resource layout.
public ShaderData.VariantCompileInfo CompileVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget)

Parameters

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.

keywords

The keywords to use during the compilation.

shaderCompilerPlatform

The shader compiler platform to compile for.

buildTarget

The build target to compile for.

Returns

Type

Description

VariantCompileInfoThe 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.
public ShaderData.VariantCompileInfo CompileVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, bool forExternalTool)

Parameters

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.

keywords

The keywords to use during the compilation.

shaderCompilerPlatform

The shader compiler platform to compile for.

buildTarget

The build target to compile for.

forExternalTool

Indicates whether to prepare the bytecode for Unity or to use with external tools.

Returns

Type

Description

VariantCompileInfoThe 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.
public ShaderData.VariantCompileInfo CompileVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, GraphicsTier tier)

Parameters

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.

keywords

The keywords to use during the compilation.

shaderCompilerPlatform

The shader compiler platform to compile for.

buildTarget

The build target to compile for.

An optional graphics tier.

Returns

Type

Description

VariantCompileInfoThe 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.
public ShaderData.VariantCompileInfo CompileVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, GraphicsTier tier, bool forExternalTool)

Parameters

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.

keywords

The keywords to use during the compilation.

shaderCompilerPlatform

The shader compiler platform to compile for.

buildTarget

The build target to compile for.

An optional graphics tier.

forExternalTool

Indicates whether to prepare the bytecode for Unity or to use with external tools.

Returns

Type

Description

VariantCompileInfoThe 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.
public ShaderData.VariantCompileInfo CompileVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, BuiltinShaderDefine[] platformKeywords)

Parameters

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.

keywords

The keywords to use during the compilation.

shaderCompilerPlatform

The shader compiler platform to compile for.

buildTarget

The build target to compile for.

platformKeywords

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

VariantCompileInfoThe 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.
public ShaderData.VariantCompileInfo CompileVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, BuiltinShaderDefine[] platformKeywords, bool forExternalTool)

Parameters

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.

keywords

The keywords to use during the compilation.

shaderCompilerPlatform

The shader compiler platform to compile for.

buildTarget

The build target to compile for.

platformKeywords

An optional set of platform keywords. If you do not provide any, Unity uses the default keywords for the given platform, target, and tier.

forExternalTool

Indicates whether to prepare the bytecode for Unity or to use with external tools.

Returns

Type

Description

VariantCompileInfoThe 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.
public ShaderData.VariantCompileInfo CompileVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, BuiltinShaderDefine[] platformKeywords, GraphicsTier tier)

Parameters

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.

keywords

The keywords to use during the compilation.

shaderCompilerPlatform

The shader compiler platform to compile for.

buildTarget

The build target to compile for.

platformKeywords

An optional set of platform keywords. If you do not provide any, Unity uses the default keywords for the given platform, target, and tier.

An optional graphics tier.

Returns

Type

Description

VariantCompileInfoThe 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.
public ShaderData.VariantCompileInfo CompileVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, BuiltinShaderDefine[] platformKeywords, GraphicsTier tier, bool forExternalTool)

Parameters

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.

keywords

The keywords to use during the compilation.

shaderCompilerPlatform

The shader compiler platform to compile for.

buildTarget

The build target to compile for.

platformKeywords

An optional set of platform keywords. If you do not provide any, Unity uses the default keywords for the given platform, target, and tier.

An optional graphics tier.

forExternalTool

Indicates whether to prepare the bytecode for Unity or to use with external tools.

Returns

Type

Description

VariantCompileInfoThe 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.