[unity3d程序] 颜色渐变效果
研究了下,颜色变化时遵从RGB圆环(就是说颜色条对接一下成环)路径最小变化原则。举个例子,加入ABCDE四个颜色点,并且A和E在同一点(转了一圈)设定从A变化到C的话,有两种路径,一种ABC,还一种ADC,究竟选择哪条路径 就看这两条路径哪个更短些了
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); }