using System;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using TMPro;

public class DynamicText : MonoBehaviour
{
    public TextMeshPro text;
    private Sequence mScoreSequence;
    private float mOldScore = 0;
    private float newScore = 0;
    public float num;
    void Awake()
    {

        mScoreSequence = DOTween.Sequence();
        mScoreSequence.SetAutoKill(false);
    }
    private void OnEnable()
    {
        newScore = num;
        DynamicNum();
    }
    void Start()
    {

    }
    public void DynamicNum()
    {
        mScoreSequence.Append(DOTween.To(delegate (float value) {
            var temp = Math.Floor(value);
            text.text = temp + "";
        }, mOldScore, newScore, 2));
        mOldScore = newScore;
    }
    private void OnDisable()
    {
        mOldScore = 0;
        newScore = 0;
    }
}
