在unity3d中用代码改变颜色,比如可以使颜色渐变。现在我们就来了解一下怎样利用代码改变颜色。
var colorStart = Color.red;
var colorEnd = Color.green;
var duration = 1.0;
var minimum = 0.0;
var maximum = 200.0;
function Update () {
var lerp = Mathf.PingPong (Time.time, duration) / duration;
renderer.material.color = Color.Lerp (colorStart, colorEnd, lerp);
transform.position.x = Mathf.Lerp(minimum, maximum, lerp);
}