Change color of "Point light" at runtime

Hello everyone.

Is there a way to change the color of a point light at runtime?

Fx from a red color to a green at runtime through script

Thank you very much

;)

Here's a link to the scripting manual that deals with this issue:

http://unity3d.com/support/documentation/ScriptReference/Light-color.html

Hello,
have a play with this!
Just attach the script to an object and attach a light into the field.
Hope it helps.


using UnityEngine;
using System.Collections;

public class LightController : MonoBehaviour {

	public int lightFactor = 0;
	
	// Light that should be controlled by the LightController
	public Light controlledLight01 = null;

	void Start () {
	}
	
	void Update () {
		
		if(controlledLight01!=null) { // If we have a light as a field
			Light l = controlledLight01.GetComponent<Light>(); // Get the Light component
			Color c = new Color();
			c.r= 1f - lightFactor / 100f;
			c.g= lightFactor / 100f;
			//c.b= lightFactor / 100f;
			c.a=1f;
			l.color = c;
		}
	}
}