Unity3d 场景中物体渐隐效果实现

using UnityEngine;

using System.Collections;


public class TestClass : MonoBehaviour {
 
 private float AlphaValue = 1.0f;
 private float time = 0.0f;
 private bool state = false;
 
 void Update() {
  
  time += Time.deltaTime;
  if(time > 0.2f){
   state = true;
   time = 0;
  }
  if(state) {
   AlphaValue -= 0.1f;
   
  }
  
  GameObject.Find("YourGameObject").renderer.material.color = new Color(0.5f, 0.3f, 1, AlphaValue);
  print(AlphaValue);
 }
}

你可能感兴趣的:(Unity3d 场景中物体渐隐效果实现)