Цвет источника света
Для изменения интенсивности света, вы изменяете яркость цвета источника света Lights always add illumination, so a light with a black color is the same as no light at all. See Also: Light component.
var lt: Light;
function Start () { lt = GetComponent.<Light>(); }
// Darken the light completely over a period of 2 seconds. function Update () { lt.color -= Color.white / 2.0 * Time.deltaTime; }
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { public Light lt; void Start() { lt = GetComponent<Light>(); } void Update() { lt.color -= Color.white / 2.0F * Time.deltaTime; } }
Другой пример:
// Interpolate light color between two colors back and forth var duration : float = 1.0; var color0 : Color = Color.red; var color1 : Color = Color.blue;
var lt: Light;
function Start () { lt = GetComponent.<Light>(); }
function Update () { // set light color var t : float = Mathf.PingPong(Time.time, duration) / duration; lt.color = Color.Lerp(color0, color1, t); }
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { public float duration = 1.0F; public Color color0 = Color.red; public Color color1 = Color.blue; public Light lt; void Start() { lt = GetComponent<Light>(); } void Update() { float t = Mathf.PingPong(Time.time, duration) / duration; lt.color = Color.Lerp(color0, color1, t); } }