直接上代码把:
void Start()
{
PingPongY(0.5f,1,2f);
}
private void PingPongY(float fromvalue, float tovalue,float duration)
{
Color temColor = gameObject.GetComponent<Image>().color;
temColor.a = fromvalue;
Tweener tweener = DOTween.ToAlpha(() => temColor, x => temColor = x, tovalue, duration);
tweener.onUpdate = () => { gameObject.GetComponent<Image>().color = temColor; };
tweener.OnComplete(() => PingPongY(tovalue, fromvalue,duration));
}