# LocalKeywordSpace

> Represents the local keyword space of a Shader or ComputeShader.

## Definition

* **Type:** Struct
* **Namespace:** [UnityEngine.Rendering](/engine/6000.0/script-reference/unityengine/rendering.md)
* **Assembly:** UnityEngine.CoreModule
* **Implements:** [IEquatable\<LocalKeywordSpace>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
public readonly struct LocalKeywordSpace : IEquatable<LocalKeywordSpace>
```

## Remarks

Shader keywords determine which shader variants Unity uses. For information on working with local shader keywords 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).

When you declare a [shader keyword](/engine/6000.0/manual/materials-and-shaders/shaders/writing-custom/shader-writing/sl-multiple-program-variants/shader-keywords.md) in the source file for a [Shader](/engine/6000.0/script-reference/unityengine/shader.md) or [ComputeShader](/engine/6000.0/script-reference/unityengine/computeshader.md), Unity represents the keyword with a [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md) and stores it in a `LocalKeywordSpace`.

For a [Shader](/engine/6000.0/script-reference/unityengine/shader.md), access the `LocalKeywordSpace` with [Shader.keywordSpace](/engine/6000.0/script-reference/unityengine/shader/keywordspace.md). It contains:

* All keywords declared in the source file. For more information, see [Declaring shader keywords](/engine/6000.0/manual/materials-and-shaders/shaders/writing-custom/shader-writing/sl-multiple-program-variants/shader-keywords.md#declaring-keywords).
* All keywords declared in dependencies of that source file. This comprises all Shaders that are included via the [Fallback command](/engine/6000.0/manual/materials-and-shaders/shaders/reference/sl-reference/sl-shader-object/sl-fallback.md), and all keywords declared in all Passes that are included via the [UsePass command](/engine/6000.0/manual/materials-and-shaders/shaders/reference/sl-reference/sl-sub-shader-object/sl-use-pass.md).
* All keywords that Unity adds automatically. For more information, see [Unity's predefined shader keywords](/engine/6000.0/manual/materials-and-shaders/shaders/writing-custom/shader-writing/sl-multiple-program-variants/shader-keywords.md#predefined-shader-keywords).

For a [ComputeShader](/engine/6000.0/script-reference/unityengine/computeshader.md), access the `LocalKeywordSpace` with [ComputeShader.keywordSpace](/engine/6000.0/script-reference/unityengine/computeshader/keywordspace.md). It contains all keywords declared in the source file. For more information, see [Declaring shader keywords](/engine/6000.0/manual/materials-and-shaders/shaders/writing-custom/shader-writing/sl-multiple-program-variants/shader-keywords.md#declaring-keywords).

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.keywordSpace](/engine/6000.0/script-reference/unityengine/computeshader/keywordspace.md), [Shader.keywordSpace](/engine/6000.0/script-reference/unityengine/shader/keywordspace.md).

## Properties

| Property                                                                                                | Description                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [keywordCount](/engine/6000.0/script-reference/unityengine/rendering/localkeywordspace/keywordcount.md) | The number of local shader keywords in this local keyword space. (Read Only)                                                                                   |
| [keywordNames](/engine/6000.0/script-reference/unityengine/rendering/localkeywordspace/keywordnames.md) | An array containing the names of all local shader keywords in this local keyword space. (Read Only)                                                            |
| [keywords](/engine/6000.0/script-reference/unityengine/rendering/localkeywordspace/keywords.md)         | An array containing all [LocalKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeyword.md) structs in this local keyword space. (Read Only) |

## Methods

| Method                                                                                                | Description                                                                 |
| ----------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| [FindKeyword](/engine/6000.0/script-reference/unityengine/rendering/localkeywordspace/findkeyword.md) | Searches for a local shader keyword with a given name in the keyword space. |

## Operators

| Operator                                                                                                | Description                                                                                 |
| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| [operator ==](/engine/6000.0/script-reference/unityengine/rendering/localkeywordspace/op-equality.md)   | Returns true if the local shader keyword spaces are the same. Otherwise, returns false.     |
| [operator !=](/engine/6000.0/script-reference/unityengine/rendering/localkeywordspace/op-inequality.md) | Returns true if the local shader keyword spaces are not the same. Otherwise, returns false. |
