CopyGraphicsStatesForVariant
Copy all the graphics states from the source variant to the destination variant.
Read time 2 minutesLast updated 10 days ago
Definition
- Type: Method
- Namespace: UnityEngine.Rendering
- Assembly: UnityEngine.CoreModule
CopyGraphicsStatesForVariant(Shader, PassIdentifier, LocalKeyword[], Shader, PassIdentifier, LocalKeyword[])
Copy all the graphics states from the source variant to the destination variant.
public bool CopyGraphicsStatesForVariant(Shader srcShader, PassIdentifier srcPassId, LocalKeyword[] srcKeywords, Shader dstShader, PassIdentifier dstPassId, LocalKeyword[] dstKeywords)
Parameters
Shader used in the source variant.
PassIdentifier used in the source variant.
LocalKeyword array of keywords used in the source variant.
Shader used in the destination variant.
PassIdentifier used in the destination variant.
LocalKeyword array of keywords used in the destination variant.
Returns
Type | Description |
|---|---|
| bool | True if at least one new graphics state was copied, false otherwise. |
Remarks
If the destination shader variant does not yet exist in the collection, then it will be added.
using System.Collections.Generic;using UnityEngine;using UnityEngine.Rendering;public class CopyGraphicsStatesExample : MonoBehaviour{ public GraphicsStateCollection graphicsStateCollection; public GraphicsStateCollection.ShaderVariant srcVariant; void Start() { if (graphicsStateCollection.ContainsVariant(srcVariant.shader, srcVariant.passId, srcVariant.keywords)) { List<GraphicsStateCollection.ShaderVariant> variants = new List<GraphicsStateCollection.ShaderVariant>(); graphicsStateCollection.GetVariants(variants); foreach (var dstVariant in variants) { graphicsStateCollection.CopyGraphicsStatesForVariant(srcVariant, dstVariant); } } else { Debug.Log("srcVariant was not found in graphicsStateCollection! No graphics states were copied."); } }}
Additional Resources: GraphicsStateCollection.GetGraphicsStatesForVariant, GraphicsStateCollection.AddGraphicsStateForVariant.
CopyGraphicsStatesForVariant(ShaderVariant, ShaderVariant)
Copy all the graphics states from the source variant to the destination variant.
public bool CopyGraphicsStatesForVariant(GraphicsStateCollection.ShaderVariant srcVariant, GraphicsStateCollection.ShaderVariant dstVariant)
Parameters
Source variant to copy from.
Destination variant to copy to.
Returns
Type | Description |
|---|---|
| bool | True if at least one new graphics state was copied, false otherwise. |
Remarks
If the destination shader variant does not yet exist in the collection, then it will be added.
using System.Collections.Generic;using UnityEngine;using UnityEngine.Rendering;public class CopyGraphicsStatesExample : MonoBehaviour{ public GraphicsStateCollection graphicsStateCollection; public GraphicsStateCollection.ShaderVariant srcVariant; void Start() { if (graphicsStateCollection.ContainsVariant(srcVariant.shader, srcVariant.passId, srcVariant.keywords)) { List<GraphicsStateCollection.ShaderVariant> variants = new List<GraphicsStateCollection.ShaderVariant>(); graphicsStateCollection.GetVariants(variants); foreach (var dstVariant in variants) { graphicsStateCollection.CopyGraphicsStatesForVariant(srcVariant, dstVariant); } } else { Debug.Log("srcVariant was not found in graphicsStateCollection! No graphics states were copied."); } }}