using UnityEngine; using System.Collections; public class TestClass : MonoBehaviour { private float AlphaValue = 1.0f; private float time = 0.0f; private bool state = false; Material material; private void Start() { material = GameObject.Find("YourGameObject").GetComponent<Renderer>().material; } void Update() { time += Time.deltaTime; if (time > 0.2f) { state = true; time = 0; } if (state) { AlphaValue -= 0.001f; } material.color = new Color(1f, 1f, 1, AlphaValue); print(AlphaValue); } }View Code
标签:float,渐变,material,state,private,Unity,AlphaValue,time,方块 From: https://www.cnblogs.com/Peng18233754457/p/18252503