Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Light.color

Switch to Manual
public var color: Color;

Description

The color of the light.

To modify the light intensity you change light's color luminance. Lights always add illumination, so a light with a black color is the same as no light at all. See Also: Light component.

	// Darken the light completely over a period of 2 seconds.
	function Update () {
		light.color -= Color.white / 2.0 * Time.deltaTime;
	}

Another example:

	// Interpolate light color between two colors back and forth
	var duration : float = 1.0;
	var color0 : Color = Color.red;
	var color1 : Color = Color.blue;
	
	function Update () {
		// set light color
		var t : float = Mathf.PingPong (Time.time, duration) / duration;
		light.color = Color.Lerp (color0, color1, t);
	}