If I have two defined colors (public Color earlyMorning = new Color (95f, 59f, 168f, 1f)
ect. How can I change the color of a light over, say, 60 seconds?
I tried light.color += earlyMorning / 60 * Time.deltaTime; however, if I log the color of the light to the console every frame, it only increases the alpha value.
So, what is the most effective method to change the color of the light over time?
If you Google “Unity3d change color over time”, you will find many hits, many with scripts. Here is one:
http://answers.unity3d.com/questions/325568/problem-with-fading-a-colour-over-time.html
I would look up color lerping…
http://docs.unity3d.com/Documentation/ScriptReference/Color.Lerp.html
if you need more help understanding the lerp function let me know.
Just attach this to the camera and set its clear flags to solid color!
var color1 : Color = Color.red;
var color2 : Color = Color.blue;
var duration = 3.0;
// Set clear flags to color
camera.clearFlags = CameraClearFlags.SolidColor;
function Update () {
var t : float = Mathf.PingPong (Time.time, duration) / duration;
camera.backgroundColor = Color.Lerp (color1, color2, t);
}