Material.color 颜色

var color : Color

Description描述

The main material's color.

主材质的颜色。

The same as using GetColor or SetColor with "_Color" name.

使用带有“_Color“的名字的GetColor或SetColor是一样的。

参考:SetColor, GetColor.

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public Color colorStart = Color.red;
	public Color colorEnd = Color.green;
	public float duration = 1.0F;
	void Update() {
		float lerp = Mathf.PingPong(Time.time, duration) / duration;
		renderer.material.color = Color.Lerp(colorStart, colorEnd, lerp);
	}
}
// Fade the color from red to green
//渐变颜色从红色到绿色
// back and forth over the defined duration
//定义循环的时间


var colorStart : Color = Color.red ;
var colorEnd : Color = Color.green ;
var duration : float = 1.0;

function Update () {
	var lerp : float = Mathf.PingPong ( Time.time , duration) / duration;
	renderer.material.color = Color.Lerp (colorStart, colorEnd, lerp);
}

Page last updated: 2011-1-21