# SetKeyword

> Adds a command to set the state of a global or local shader keyword.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.Rendering](/engine/6000.0/script-reference/unityengine/rendering.md)
* **Assembly:** UnityEngine.CoreModule

## SetKeyword(GlobalKeyword, bool)

Adds a command to set the state of a global or local shader keyword.

```csharp
public void SetKeyword(in GlobalKeyword keyword, bool value)
```

### Parameters

**** (\[GlobalKeyword]\(/engine/6000.0/script-reference/unityengine/rendering/globalkeyword)): The local or global shader keyword to set the state for.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): The state to set the shader keyword state to.

### Remarks

Shader keywords determine which shader variants Unity uses. For information on working with [local shader keywords](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md) and [global shader keywords](/engine/6000.0/script-reference/unityengine/rendering/globalkeyword.md) and how they interact, see [Using shader keywords with C# scripts](/engine/6000.0/manual/materials-and-shaders/shaders/writing-custom/shader-writing/sl-multiple-program-variants/shader-keywords-scripts.md).

Additional Resources: Shader variants and keywords, [CommandBuffer.DisableKeyword](/engine/6000.0/script-reference/unityengine/rendering/commandbuffer/disablekeyword.md), [CommandBuffer.EnableKeyword](/engine/6000.0/script-reference/unityengine/rendering/commandbuffer/enablekeyword.md), [GlobalKeyword](/engine/6000.0/script-reference/unityengine/rendering/globalkeyword.md), [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md), [Shader.SetKeyword](/engine/6000.0/script-reference/unityengine/shader/setkeyword.md), [Material.SetKeyword](/engine/6000.0/script-reference/unityengine/material/setkeyword.md), [ComputeShader.SetKeyword](/engine/6000.0/script-reference/unityengine/computeshader/setkeyword.md).

## SetKeyword(Material, LocalKeyword, bool)

Adds a command to set the state of a global or local shader keyword.

```csharp
public void SetKeyword(Material material, in LocalKeyword keyword, bool value)
```

### Parameters

**** (\[Material]\(/engine/6000.0/script-reference/unityengine/material)): The material for which to set the state of the local shader keyword.**** (\[LocalKeyword]\(/engine/6000.0/script-reference/unityengine/rendering/localkeyword)): The local or global shader keyword to set the state for.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): The state to set the shader keyword state to.

### Remarks

Shader keywords determine which shader variants Unity uses. For information on working with [local shader keywords](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md) and [global shader keywords](/engine/6000.0/script-reference/unityengine/rendering/globalkeyword.md) and how they interact, see [Using shader keywords with C# scripts](/engine/6000.0/manual/materials-and-shaders/shaders/writing-custom/shader-writing/sl-multiple-program-variants/shader-keywords-scripts.md).

Additional Resources: Shader variants and keywords, [CommandBuffer.DisableKeyword](/engine/6000.0/script-reference/unityengine/rendering/commandbuffer/disablekeyword.md), [CommandBuffer.EnableKeyword](/engine/6000.0/script-reference/unityengine/rendering/commandbuffer/enablekeyword.md), [GlobalKeyword](/engine/6000.0/script-reference/unityengine/rendering/globalkeyword.md), [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md), [Shader.SetKeyword](/engine/6000.0/script-reference/unityengine/shader/setkeyword.md), [Material.SetKeyword](/engine/6000.0/script-reference/unityengine/material/setkeyword.md), [ComputeShader.SetKeyword](/engine/6000.0/script-reference/unityengine/computeshader/setkeyword.md).

## SetKeyword(ComputeShader, LocalKeyword, bool)

Adds a command to set the state of a global or local shader keyword.

```csharp
public void SetKeyword(ComputeShader computeShader, in LocalKeyword keyword, bool value)
```

### Parameters

**** (\[ComputeShader]\(/engine/6000.0/script-reference/unityengine/computeshader)): The compute shader for which to set the state of the local shader keyword.**** (\[LocalKeyword]\(/engine/6000.0/script-reference/unityengine/rendering/localkeyword)): The local or global shader keyword to set the state for.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): The state to set the shader keyword state to.

### Remarks

Shader keywords determine which shader variants Unity uses. For information on working with [local shader keywords](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md) and [global shader keywords](/engine/6000.0/script-reference/unityengine/rendering/globalkeyword.md) and how they interact, see [Using shader keywords with C# scripts](/engine/6000.0/manual/materials-and-shaders/shaders/writing-custom/shader-writing/sl-multiple-program-variants/shader-keywords-scripts.md).

Additional Resources: Shader variants and keywords, [CommandBuffer.DisableKeyword](/engine/6000.0/script-reference/unityengine/rendering/commandbuffer/disablekeyword.md), [CommandBuffer.EnableKeyword](/engine/6000.0/script-reference/unityengine/rendering/commandbuffer/enablekeyword.md), [GlobalKeyword](/engine/6000.0/script-reference/unityengine/rendering/globalkeyword.md), [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md), [Shader.SetKeyword](/engine/6000.0/script-reference/unityengine/shader/setkeyword.md), [Material.SetKeyword](/engine/6000.0/script-reference/unityengine/material/setkeyword.md), [ComputeShader.SetKeyword](/engine/6000.0/script-reference/unityengine/computeshader/setkeyword.md).
