using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ChangeNumber : MonoBehaviour
{
public TextMeshProUGUI showText;
public float time = 3f;
public float currentVaule = 0f;
public float targetVaule = 115f;
public int index;
private void Start()
{
showText = gameObject.GetComponent<TextMeshProUGUI>();
}
public void DataIncrement()
{
currentVaule += Time.deltaTime * (targetVaule / time);
if (currentVaule >= targetVaule)
{
currentVaule = targetVaule;
}
showText.text = currentVaule.ToString("0");
switch (index)
{
case 1:
showText.text = currentVaule.ToString("0.0");
break;
case 2:
showText.text = currentVaule.ToString("0.00");
break;
default:
showText.text = currentVaule.ToString("0");
break;
}
}
private void Update()
{
DataIncrement();
}
}