Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


CopyGraphicsStatesForVariant

Copy all the graphics states from the source variant to the destination variant.
Read time 2 minutesLast updated 10 days ago

Definition

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

srcShader

Shader used in the source variant.

PassIdentifier used in the source variant.

srcKeywords

LocalKeyword array of keywords used in the source variant.

dstShader

Shader used in the destination variant.

PassIdentifier used in the destination variant.

dstKeywords

LocalKeyword array of keywords used in the destination variant.

Returns

Type

Description

boolTrue 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."); } }}

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

srcVariant

Source variant to copy from.

dstVariant

Destination variant to copy to.

Returns

Type

Description

boolTrue 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."); } }}