- Home /
Question by
thyshimrod · Feb 07, 2018 at 08:52 AM ·
scripting beginnermaterial color
Emissive color on material scripting
Hello,
I wish to change dynamically this value on a material. Which way can I do that?
Thank you
emiisive.png
(26.0 kB)
Comment
Answer by UnitedCoders · Feb 07, 2018 at 10:03 AM
using UnityEngine;
using System.Collections;
public class EmissiveColorSet : MonoBehaviour {
public Color _color;
public Material mat;
void Start() {
}
void Update()
{
mat.SetColor("_EmissionColor", _color);
}
}
It is not the color I wish to change, but value on the box into the red circle I made. The multiplier?
Answer by thyshimrod · Feb 07, 2018 at 07:15 PM
I tried something like this:
render.material.EnableKeyword("_EMISSION");
DynamicGI.SetEmissive(render, new Color(1f, 0.0f, 0.0f, 1.0f) * 10);
render.UpdateGIMaterials();
DynamicGI.UpdateEnvironment();
But I didnt succeed to scale the emissive dynamically during game.
I wonder if there is some pre requisite on the material to activate, or in the environment?