Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Why Material.shaderKeywords returns out of date values?

Discussion in 'General Graphics' started by jayatubi, May 14, 2020.

  1. jayatubi

    jayatubi

    Joined:
    Dec 9, 2013
    Posts:
    143
    I tried these steps:
    1. Create a material with ShaderA;
    2. Enable or disable some keywords on then material;
    3. Then the shader of the material to ShaderB which provides some different keywords;
    4. When I was going to get the Material.shaderKeywords of the material the result contains keywords from the previous ShaderA.

    How to avoid this? How to make Material.shaderKeywords returns the keywords only with current associated shader?
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,890
  3. jayatubi

    jayatubi

    Joined:
    Dec 9, 2013
    Posts:
    143
    I'd like to gather the using keywords among my materials for my custom shader stripper but the Material.shaderKeywords can't give me the actually validate keywords combination for it associated shader.
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,890
  5. jayatubi

    jayatubi

    Joined:
    Dec 9, 2013
    Posts:
    143
    OK, I'll try.