示例
using DG.Tweening; using UnityEngine; using UnityEngine.UI; public class FlashWord : MonoBehaviour { private void Start() { Pingpong(1, 0, 0.6f); } void Pingpong(float fromValue, float toValue, float duration) { Color temColor = gameObject.GetComponent<Text>().color; temColor.a = fromValue; Tweener tweener = DOTween.ToAlpha(() => temColor, x => temColor = x, toValue, duration); tweener.onUpdate = () => { gameObject.GetComponent<Text>().color = temColor; }; tweener.onComplete = () => { Pingpong(toValue, fromValue, duration); }; } }
上述代码可以实现将字体的显隐变换效果,将<Text>改为<Image>可以实现图片的显隐效果。
标签:fromValue,toValue,Text,float,Pingpong,temColor,隐形,字体,duration From: https://www.cnblogs.com/gatran/p/17206118.html