| Parameter | Description |
|---|---|
| srcShader | Shader used in the source variant. |
| srcPassId | PassIdentifier used in the source variant. |
| srcKeywords | LocalKeyword array of keywords used in the source variant. |
| srcVariant | Source variant to copy from. |
| dstShader | Shader used in the destination variant. |
| dstPassId | PassIdentifier used in the destination variant. |
| dstKeywords | LocalKeyword array of keywords used in the destination variant. |
| dstVariant | Destination variant to copy to. |
Boolean True if at least one new graphics state was copied, false otherwise.
Copy all the graphics states from the source variant to the destination variant.
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.Experimental.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: GetGraphicsStatesForVariant, AddGraphicsStateForVariant.