Unity简单操作:使用DOTween实现数字滚动累积效果

  • Post author:
  • Post category:其他



    public int type;
    public void IncreaseAnimInit(int startValue, float targetValue,Text useTxt)
    {
        var se = DOTween.Sequence();
        se.Append(DOTween.To(delegate (float value)
        {
            var temp = Mathf.FloorToInt(value);
            if (type == 1)
            {
                useTxt.text = "+" + temp .ToString();
            }
            else
            {
                useTxt.text ="$"+ temp  .ToString();
            }

        }, startValue, targetValue, 2f));
    }
    public void IncreaseAnimFloat(float startValue, float targetValue,Text useTxt)
    {
        var se = DOTween.Sequence();
        se.Append(DOTween.To(delegate (float value)
        {
            //var temp = Mathf.FloorToInt(value);
            if (type == 1)
            {
                useTxt.text = "+" + value .ToString("0.00");
            }
            else
            {
                useTxt.text ="$"+ value  .ToString("0.00");
            }

        }, startValue, targetValue, 2f));
    }



版权声明:本文为weixin_39114763原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。