unity3d-material
pragma strict
var alpha;
var fadeSpeed : float=10;
var timeLeft:float=10;
var rotationSpeed:float = 100.0f;
function Start () {
}
function Update () {
transform.Rotate(Vector3(0,rotationSpeed*Time.deltaTime,0));
if (gameObject.renderer.material.color.a ; 0)
{
timeLeft = timeLeft - Time.deltaTime;
alpha = (timeLeft/fadeSpeed);
gameObject.renderer.material.color.a=alpha ;
gameObject.transform.position.y+=0.002;
}
}
利用上面的代码只能改变Material中Element 0,改变不了element2,element3