Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


AddVariant

Adds a new shader variant to the collection.
Read time 2 minutesLast updated 7 days ago

Definition

AddVariant(Shader, PassIdentifier, LocalKeyword[])

Adds a new shader variant to the collection.
public bool AddVariant(Shader shader, PassIdentifier passId, LocalKeyword[] keywords)

Parameters

shader

Shader used in the variant.

PassIdentifier used in the variant.

LocalKeyword array of keywords used in the variant.

Returns

Type

Description

boolTrue if a new variant was added, false otherwise.

Remarks

If only the
material
is provided, then the generated ShaderVariantCollection.ShaderVariant will use the set of Material.enabledKeywords combined with the global shader keywords that are currently enabled in the active context, unless explicitly provided via
globalKeywords
.

AddVariant(Material, PassIdentifier)

Adds a new shader variant to the collection.
public bool AddVariant(Material mat, PassIdentifier passId)

Parameters


PassIdentifier used in the variant.

Returns

Type

Description

boolTrue if a new variant was added, false otherwise.

Remarks

If only the
material
is provided, then the generated ShaderVariantCollection.ShaderVariant will use the set of Material.enabledKeywords combined with the global shader keywords that are currently enabled in the active context, unless explicitly provided via
globalKeywords
.

AddVariant(Material, PassIdentifier, GlobalKeyword[])

Adds a new shader variant to the collection.
public bool AddVariant(Material mat, PassIdentifier passId, GlobalKeyword[] globalKeywords)

Parameters


PassIdentifier used in the variant.

globalKeywords

GlobalKeyword array of global keywords to use with the material's enabled keywords in the variant.

Returns

Type

Description

boolTrue if a new variant was added, false otherwise.

Remarks

If only the
material
is provided, then the generated ShaderVariantCollection.ShaderVariant will use the set of Material.enabledKeywords combined with the global shader keywords that are currently enabled in the active context, unless explicitly provided via
globalKeywords
.