using System.Collections; using System.Collections.Generic; using UnityEngine; public class FaGuangItem : MonoBehaviour { private Material material; private float value; private float speed = 5f; private Color color; // Start is called before the first frame update void Start() { material = this.GetComponent().material; color = material.color; } // Update is called once per frame void Update() { value += speed * Time.deltaTime; if (value >= 1) { speed = -2; } if (value <=0 ) { speed = 2; } float factor = Mathf.Pow(2, value); material.SetColor("_EmissionColor", new Color(color.r * factor, color.g * factor, color.b * factor)); } }