(posting here because I think I’ll have a better chance of getting an answer)
Originally I was just trying to modify the EmissionScale in the shader and was referred to the following link…
I’m just trying to toggle the emission on/off. The documentation (link below) says there are 3 parameters, but it will only accept 2. And I am puzzled as to why I can’t control the emission with the emission value? Instead I have to jerk around with the color. In any case, it’s not working, can someone give me a hand with this? Thanks.
public class Lights : MonoBehaviour
{
private Renderer renderer;
private Material material;
private float emissionValue;
private Color white = new Color(1f,1f,1f,1f);
private Color black = new Color(0f,0f,0f,1f);
private bool isOn = true;
void Awake()
{
renderer = GetComponent<Renderer>();
material = renderer.sharedMaterial;
emissionValue = material.GetFloat ("_EmissionScaleUI");
Debug.Log (this.transform.name);
Debug.Log (emissionValue.ToString ());
}
public void ToggleLights()
{
isOn = !isOn;
if (!isOn)
{
Debug.Log ("Off");
DynamicGI.SetEmissive(renderer, (black * emissionValue));
}
else
{
Debug.Log ("On");
DynamicGI.SetEmissive(renderer, (white * emissionValue));
}
DynamicGI.UpdateMaterials(renderer);
DynamicGI.UpdateEnvironment();
}
}