Light.color 颜色

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.

修改的灯光强度(intensity),可以改变灯光颜色的亮度。灯光总是增加照明,因此一个黑色光源和没有光一样。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void Update() {
		light.color -= Color.white / 2.0F * Time.deltaTime;
	}
}
// Darken the light completely over a period of 2 seconds.
//在2秒内使颜色变黑。

function Update () {
	light.color -= Color.white / 2.0 * Time.deltaTime;
}

另一个例子:

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public float duration = 1.0F;
	public Color color0 = Color.red;
	public Color color1 = Color.blue;
	void Update() {
		float t = Mathf.PingPong(Time.time, duration) / duration;
		light.color = Color.Lerp(color0, color1, t);
	}
}
// Interpolate light color between two colors back and forth
//在2个颜色之间来回插值光源颜色。
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);
}
Page last updated: 2011-3-30