# DisableKeyword

> Disables a local shader keyword for this compute shader.

## Definition

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

## DisableKeyword(string)

Disables a local shader keyword for this compute shader.

```csharp
public void DisableKeyword(string keyword)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md) to disable.

### 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).

If you pass in a [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md) and it does not exist in the [ComputeShader.keywordSpace](/engine/6000.0/script-reference/unityengine/computeshader/keywordspace.md), this function has no effect. If you pass a string and a [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md) with that `name` does not exist in the [ComputeShader.keywordSpace](/engine/6000.0/script-reference/unityengine/computeshader/keywordspace.md), this function has no effect.

The version of this function that takes a string as a parameter is slower than the version that takes a [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md). If you call this function more than once, it is best practice to create a [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md) struct, cache it, and use that.

**Note:** A `LocalKeyword` is specific to a single [Shader](/engine/6000.0/script-reference/unityengine/shader.md) or [ComputeShader](/engine/6000.0/script-reference/unityengine/computeshader.md) instance. You cannot use it with other [Shader](/engine/6000.0/script-reference/unityengine/shader.md) or [ComputeShader](/engine/6000.0/script-reference/unityengine/computeshader.md) instances, even if they declare keywords with the same name.

The following example creates a `LocalKeyword` struct with the name `EXAMPLE_FEATURE_ON`, and caches it. It provides functions to enable and disable it.

```csharp
using UnityEngine;
using UnityEngine.Rendering;

public class ComputeKeywordExample : MonoBehaviour
{
    public ComputeShader computeShader;
    private LocalKeyword exampleFeatureKeyword;

    void Start()
    {
        // Create and cache the LocalKeyword
        exampleFeatureKeyword = new LocalKeyword(computeShader, "EXAMPLE_FEATURE_ON");
    }

    public void EnableExampleFeature()
    {
        computeShader.EnableKeyword(exampleFeatureKeyword);
    }

    public void DisableExampleFeature()
    {
        computeShader.DisableKeyword(exampleFeatureKeyword);
    }
}
```

Additional Resources: Shader variants and keywords, [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md), [GlobalKeyword](/engine/6000.0/script-reference/unityengine/rendering/globalkeyword.md), [ComputeShader.EnableKeyword](/engine/6000.0/script-reference/unityengine/computeshader/enablekeyword.md), [ComputeShader.SetKeyword](/engine/6000.0/script-reference/unityengine/computeshader/setkeyword.md), [ComputeShader.keywordSpace](/engine/6000.0/script-reference/unityengine/computeshader/keywordspace.md), [ComputeShader.IsKeywordEnabled](/engine/6000.0/script-reference/unityengine/computeshader/iskeywordenabled.md), [ComputeShader.enabledKeywords](/engine/6000.0/script-reference/unityengine/computeshader/enabledkeywords.md), [ComputeShader.shaderKeywords](/engine/6000.0/script-reference/unityengine/computeshader/shaderkeywords.md).

## DisableKeyword(LocalKeyword)

Disables a local shader keyword for this compute shader.

```csharp
public void DisableKeyword(in LocalKeyword keyword)
```

### Parameters

**** (\[LocalKeyword]\(/engine/6000.0/script-reference/unityengine/rendering/localkeyword)): The [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md) to disable.

### 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).

If you pass in a [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md) and it does not exist in the [ComputeShader.keywordSpace](/engine/6000.0/script-reference/unityengine/computeshader/keywordspace.md), this function has no effect. If you pass a string and a [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md) with that `name` does not exist in the [ComputeShader.keywordSpace](/engine/6000.0/script-reference/unityengine/computeshader/keywordspace.md), this function has no effect.

The version of this function that takes a string as a parameter is slower than the version that takes a [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md). If you call this function more than once, it is best practice to create a [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md) struct, cache it, and use that.

**Note:** A `LocalKeyword` is specific to a single [Shader](/engine/6000.0/script-reference/unityengine/shader.md) or [ComputeShader](/engine/6000.0/script-reference/unityengine/computeshader.md) instance. You cannot use it with other [Shader](/engine/6000.0/script-reference/unityengine/shader.md) or [ComputeShader](/engine/6000.0/script-reference/unityengine/computeshader.md) instances, even if they declare keywords with the same name.

The following example creates a `LocalKeyword` struct with the name `EXAMPLE_FEATURE_ON`, and caches it. It provides functions to enable and disable it.

```csharp
using UnityEngine;
using UnityEngine.Rendering;

public class ComputeKeywordExample : MonoBehaviour
{
    public ComputeShader computeShader;
    private LocalKeyword exampleFeatureKeyword;

    void Start()
    {
        // Create and cache the LocalKeyword
        exampleFeatureKeyword = new LocalKeyword(computeShader, "EXAMPLE_FEATURE_ON");
    }

    public void EnableExampleFeature()
    {
        computeShader.EnableKeyword(exampleFeatureKeyword);
    }

    public void DisableExampleFeature()
    {
        computeShader.DisableKeyword(exampleFeatureKeyword);
    }
}
```

Additional Resources: Shader variants and keywords, [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md), [GlobalKeyword](/engine/6000.0/script-reference/unityengine/rendering/globalkeyword.md), [ComputeShader.EnableKeyword](/engine/6000.0/script-reference/unityengine/computeshader/enablekeyword.md), [ComputeShader.SetKeyword](/engine/6000.0/script-reference/unityengine/computeshader/setkeyword.md), [ComputeShader.keywordSpace](/engine/6000.0/script-reference/unityengine/computeshader/keywordspace.md), [ComputeShader.IsKeywordEnabled](/engine/6000.0/script-reference/unityengine/computeshader/iskeywordenabled.md), [ComputeShader.enabledKeywords](/engine/6000.0/script-reference/unityengine/computeshader/enabledkeywords.md), [ComputeShader.shaderKeywords](/engine/6000.0/script-reference/unityengine/computeshader/shaderkeywords.md).
