- Home /
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
Changed to this:
renderer.material.SetFloat("_EmissionScale", 1);
renderer.material.SetColor("_EmissionColor", Color.yellow);
Still does nothing until the material is clicked on in the inspector.
Answer by duck · Jul 10, 2015 at 04:06 PM
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:
http://docs.unity3d.com/Manual/MaterialsAccessingViaScript.html
Your answer
Follow this Question
Related Questions
Unity 5.6: Shader Broken and Showing Up Black 0 Answers
Material doesn't have a color property '_Color' 4 Answers
Changing Emission Scale UI with Script 0 Answers
Fade emission color using standard shader 1 Answer
Unity HDRP, Objects not using emission 0 Answers