Search Unity

Question Changing URP Material Properties via Script will change the values, but not the actual material

Discussion in 'Universal Render Pipeline' started by FlashMuller, Aug 5, 2022.

  1. FlashMuller

    FlashMuller

    Joined:
    Sep 25, 2013
    Posts:
    450
    I have a URP Simple Lit Material which uses Specular Highlights (enabled by default - so the Shader Variant stays the same throughout the process).
    I want to change the Smoothness via Script.
    This is the line of code:
    Code (CSharp):
    1. wood.sharedMaterial.SetFloat("_Smoothness", s.value); //s is a slider
    This does work. When I use the slider I can see the Smoothness-Value of the material change accordingly in the inspector.
    But the Material itself does not change at all - even with obvious changes from 0 to 1. The way it renders stays the same. Only after I touch the slider in the Editor / Inspector it will "apply" the values.
    What am I missing? Do I need to call some sort of Apply Changes Functionality?