AddVariants
Adds one or more new shader variants to the collection.
Read time 2 minutesLast updated 4 days ago
Definition
- Type: Method
- Namespace: UnityEngine.Rendering
- Assembly: UnityEngine.CoreModule
AddVariants(Material, int)
Adds one or more new shader variants to the collection.
public bool AddVariants(Material mat, int subshaderIndex = -1)
Parameters
Returns
Type | Description |
|---|---|
| bool | True if at least one new variant was added, false otherwise. |
Remarks
If is not specified, then one ShaderVariantCollection.ShaderVariant will attempt to be added for each shader pass in every SubShader of the parameter's Shader. Otherwise, at most Shader.GetPassCountInSubshader number of variants will be added using the specified .
subshaderIndexmaterialsubshaderIndexAll generated shader variants 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 .
globalKeywordsAdditional Resources: GraphicsStateCollection.AddVariant, GraphicsStateCollection.RemoveVariant, GraphicsStateCollection.ContainsVariant.
AddVariants(Material, GlobalKeyword[], int)
Adds one or more new shader variants to the collection.
public bool AddVariants(Material mat, GlobalKeyword[] globalKeywords, int subshaderIndex = -1)
Parameters
GlobalKeyword array of global keywords to use with the material's enabled keywords in the variants.
The index of the subshader within the shader used in the variant.
Returns
Type | Description |
|---|---|
| bool | True if at least one new variant was added, false otherwise. |
Remarks
If is not specified, then one ShaderVariantCollection.ShaderVariant will attempt to be added for each shader pass in every SubShader of the parameter's Shader. Otherwise, at most Shader.GetPassCountInSubshader number of variants will be added using the specified .
subshaderIndexmaterialsubshaderIndexAll generated shader variants 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