ImageBlinkEffect.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | using UnityEngine; using UnityEngine.UI; public class ImageBlinkEffect : MonoBehaviour { public Color startColor = Color.green; public Color endColor = Color.black; [Range(0,10)] public float speed = 1; Image imgComp; void Awake() { imgComp = GetComponent<Image>(); } void Update() { imgComp.color = Color.Lerp(startColor, endColor, Mathf.PingPong(Time.time * speed, 1)); } } |