Search Unity

Bug LocalKeyword not recognized

Discussion in 'Editor & General Support' started by jehan786, Aug 26, 2022.

  1. jehan786

    jehan786

    Joined:
    Sep 8, 2021
    Posts:
    6
    Hi, I created a new Unity project, and just created a script like in this documentation example :

    https://docs.unity3d.com/ScriptReference/Material.EnableKeyword.html

    I wrote the same script :

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Rendering;
    3.  
    4. public class MaterialKeywordExample : MonoBehaviour
    5. {
    6.     public Material material;
    7.     private LocalKeyword exampleFeatureKeyword;
    8.  
    9.     void Start()
    10.     {
    11.         // Get the instance of the Shader class that this material uses
    12.         var shader = material.shader;
    13.  
    14.         // Create and cache the LocalKeyword
    15.         exampleFeatureKeyword = new LocalKeyword(shader, "EXAMPLE_FEATURE_ON");
    16.     }
    17.  
    18.     public void EnableExampleFeature()
    19.     {
    20.         material.EnableKeyword(exampleFeatureKeyword);
    21.     }
    22.  
    23.     public void DisableExampleFeature()
    24.     {
    25.         material.DisableKeyword(exampleFeatureKeyword);
    26.     }
    27. }
    and LocalKeyword is not recognized by visual studio, as well as keywordSpace and others...

    codeLocalKeyword.png

    the error in the console is the following : The type or namespace name 'LocalKeyword' could not be found (are you missing a using directive or an assembly reference?)

    well I have visual studio editor last package installed
    visualStudioInstalled.png

    how to make visual studio recognize LocalKeyword ?

    why doesn't he recognize it ?

    thanks !!
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,925
    What version of Unity are you on? This seems to be a 2021+ feature.
     
  3. jehan786

    jehan786

    Joined:
    Sep 8, 2021
    Posts:
    6
    ok, ty !