Modifying properties of the Standard shader

Hello, so I use this:

renderer = GetComponent<Renderer>();
renderer.material.SetFloat("_EmissionScaleUI", 1);
renderer.material.SetColor("_EmissionColorUI", Color.yellow);

Emission is set to 1 in the editor, but it doesn’t update in game unless I move the slider manually.

Is there any way to make the material update or something?

Thanks

The reason is that your material does not initially use any emission (the value is zero), so that “variant” of the shader is not enabled in your material.

To make this work, either start your material off with a very low token value for emissive, or use the EnableKeyword function, as described here: