unity3d.com浅析DoTween插件用法示例

UI循环缩放的动画

public void ScaleUIEffect(Transform ts, float delayTime = 0)
{
    Tweener DoScale1 = ts.DOScale(new Vector3(1.1f, 1.1f, 1.1f), 0.3f);
    DoScale1.SetDelay(delayTime);
    DoScale1.onComplete = () =>
    {
        if (ts != null && ts.gameObject.activeInHierarchy)
        {
            Tweener DoScale2 = ts.DOScale(new Vector3(1f, 1f, 1f), 1f);
            DoScale2.onComplete = () =>
            {
                //判断当前UI是否隐藏或者销毁
                if (ts != null && ts.gameObject.activeInHierarchy)
                {
                    ScaleUIEffect(ts);
                }
            };
        }
    };
}

数值变化

public void FillProcess(float targetNum, float startNum){
    //函数内初始化
    Sequence mScoreSequence = DOTween.Sequence();
    //函数内设置属性
    mScoreSequence.SetAutoKill(false);
    mScoreSequence.Append(DOTween.To(delegate (float value)
    {
        //向下取整
        long temp = (long)System.Math.Floor(value);
     //根据需要对temp进行操作
        Debug.Log(temp);
    }, startNum, targetNum, 1f));
}

 

未经允许不得转载:第一Unity3D » unity3d.com浅析DoTween插件用法示例

赞 (0)