123456789101112131415161718192021222324252627282930313233343536373839404142 |
- 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;
- }
- }
|