# DisableKeyword

> Disables a local shader keyword for this material.

## Definition

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

## DisableKeyword(string)

Disables a local shader keyword for this material.

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

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The [LocalKeyword](/engine/6000.7/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.7/script-reference/unityengine/rendering/localkeyword.md) and [global shader keywords](/engine/6000.7/script-reference/unityengine/rendering/globalkeyword.md) and how they interact, see [Using shader keywords with C# scripts](/engine/6000.7/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.7/script-reference/unityengine/rendering/localkeyword.md) and it does not exist in the [Shader.keywordSpace](/engine/6000.7/script-reference/unityengine/shader/keywordspace.md) for the shader that this material uses, this function has no effect. If you pass a string and a [LocalKeyword](/engine/6000.7/script-reference/unityengine/rendering/localkeyword.md) with that `name` does not exist in the [Shader.keywordSpace](/engine/6000.7/script-reference/unityengine/shader/keywordspace.md) for the shader that this material uses, 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.7/script-reference/unityengine/rendering/localkeyword.md). If you call this function more than once, it is best practice to create a [LocalKeyword](/engine/6000.7/script-reference/unityengine/rendering/localkeyword.md) struct, cache it, and use that.

**Note:** A `LocalKeyword` is specific to a single [Shader](/engine/6000.7/script-reference/unityengine/shader.md) or [ComputeShader](/engine/6000.7/script-reference/unityengine/computeshader.md) instance. You cannot use it with other [Shader](/engine/6000.7/script-reference/unityengine/shader.md) or [ComputeShader](/engine/6000.7/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 MaterialKeywordExample : MonoBehaviour
{
    public Material material;
    private LocalKeyword exampleFeatureKeyword;

    void Start()
    {
        // Get the instance of the Shader class that this material uses
        var shader = material.shader;

        // Create and cache the LocalKeyword
        exampleFeatureKeyword = new LocalKeyword(shader, "EXAMPLE_FEATURE_ON");
    }

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

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

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

## DisableKeyword(LocalKeyword)

Disables a local shader keyword for this material.

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

### Parameters

**** (\[LocalKeyword]\(/engine/6000.7/script-reference/unityengine/rendering/localkeyword)): The [LocalKeyword](/engine/6000.7/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.7/script-reference/unityengine/rendering/localkeyword.md) and [global shader keywords](/engine/6000.7/script-reference/unityengine/rendering/globalkeyword.md) and how they interact, see [Using shader keywords with C# scripts](/engine/6000.7/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.7/script-reference/unityengine/rendering/localkeyword.md) and it does not exist in the [Shader.keywordSpace](/engine/6000.7/script-reference/unityengine/shader/keywordspace.md) for the shader that this material uses, this function has no effect. If you pass a string and a [LocalKeyword](/engine/6000.7/script-reference/unityengine/rendering/localkeyword.md) with that `name` does not exist in the [Shader.keywordSpace](/engine/6000.7/script-reference/unityengine/shader/keywordspace.md) for the shader that this material uses, 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.7/script-reference/unityengine/rendering/localkeyword.md). If you call this function more than once, it is best practice to create a [LocalKeyword](/engine/6000.7/script-reference/unityengine/rendering/localkeyword.md) struct, cache it, and use that.

**Note:** A `LocalKeyword` is specific to a single [Shader](/engine/6000.7/script-reference/unityengine/shader.md) or [ComputeShader](/engine/6000.7/script-reference/unityengine/computeshader.md) instance. You cannot use it with other [Shader](/engine/6000.7/script-reference/unityengine/shader.md) or [ComputeShader](/engine/6000.7/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 MaterialKeywordExample : MonoBehaviour
{
    public Material material;
    private LocalKeyword exampleFeatureKeyword;

    void Start()
    {
        // Get the instance of the Shader class that this material uses
        var shader = material.shader;

        // Create and cache the LocalKeyword
        exampleFeatureKeyword = new LocalKeyword(shader, "EXAMPLE_FEATURE_ON");
    }

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

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

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