[code=javascript]
// Pulse light's intensity over time
//随时间改变光照强度
var duration : float= 1.0;
function Update() {
// argument for cosine
//余弦理论
var phi : float = Time.time / duration * 2 * Mathf.PI;
// get cosine and transform from -1..1 to 0..1 range
//获取余弦,并将范围从-1~1变为0~1
var amplitude : float = Mathf.Cos( phi ) * 0.5 + 0.5;
// set light color
//设置灯光颜色
light.intensity = amplitude;
}[/code]