I need my directional light object to slowly change its color from white to blue. How can i do this in c#? Thanks for help!
Hello @studioglitch
try this:
public class ColorChanger: MonoBehaviour {
public Light light;
public float r=1;
public float g=1;
public float b=1;
public float smooth = 100;
void Start(){
light.color = new Color(r, g, b);
}
void Update(){
r -= Time.deltaTime/smooth;
g -= Time.deltaTime/smooth;
light.color = new Color (r, g, b);
if (r <= 0) {r = 0; }
if (g <= 0) {g = 0; }
}
}
If you want to do it with code, Gradient is the best interface.
[SerialiseField] Light light;
[SerialiseField] Gradient gradient;
float position;
light.color = gradient.Evaluate (position);
Not possible with an Animation, using c# to activated it?