Search Unity

Runtime setting _NormalMap on HDRP/Lit doesn't work until EditorGUI change

Discussion in 'General Graphics' started by max_coding13, Mar 22, 2019.

  1. max_coding13

    max_coding13

    Joined:
    Apr 24, 2016
    Posts:
    34
    I'm setting the _NormalMap property of a HDRP/Lit material during runtime and experiencing strange behavior. After setting the texture, the texture will display in the material editor as if it loaded correctly, but the material itself doesn't show the normal map. However, if I change any value on the material editor, through user input, the material "rebuilds" itself and the normal map displays correctly.

    After looking at the source code I'm guessing this is related to the method EditorGUI.BeginChangeCheck() that the Editor calls on user input.

    Is there a way to hit this same rebuilding process through script after I set my normal map texture?
     
    Last edited: Mar 22, 2019
  2. max_coding13

    max_coding13

    Joined:
    Apr 24, 2016
    Posts:
    34
    This was resolved on another thread.
    I had to use enableKeyword on the Lit material, to manually enable my normal map to be recognized.