using UnityEngine;using System.Collections;using UnityEngine.UI;using System.Collections.Generic;public class TwinkleImg : MonoBehaviour{private Image img;private float alpha = 1f;//初始的透明度private float f = 1f;//闪烁的速率void Start(){img = GetComponent<Image>();}void Update(){if (alpha >= 1f){f = -Mathf.Abs(f);}else if (alpha <= 0f){f = Mathf.Abs(f);}alpha += Time.deltaTime * f;img.color = new Color(img.color.r, img.color.g, img.color.b, alpha);}}
如果觉得《实现图片的闪烁效果》对你有帮助,请点赞、收藏,并留下你的观点哦!