39 lines
934 B
C#
39 lines
934 B
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
public class Tools : MonoBehaviour
|
|||
|
{
|
|||
|
// Start is called before the first frame update
|
|||
|
|
|||
|
void Start()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
public static IEnumerator AnimateText(float startValue, float endValue, float time, Text SetText)
|
|||
|
{
|
|||
|
float elapsedTime = 0f; // <20>Ѿ<EFBFBD><D1BE><EFBFBD>ȥ<EFBFBD><C8A5>ʱ<EFBFBD><CAB1>
|
|||
|
while (elapsedTime < time)
|
|||
|
{
|
|||
|
elapsedTime += Time.deltaTime;
|
|||
|
float t = elapsedTime / time;
|
|||
|
|
|||
|
// <20><><EFBFBD>㵱ǰֵ<C7B0><D6B5>ʹ<EFBFBD><CAB9> Mathf.Lerp <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD>ֵ
|
|||
|
int currentValue = Mathf.RoundToInt(Mathf.Lerp(startValue, endValue, t));
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ʾ
|
|||
|
SetText.text = currentValue.ToString();
|
|||
|
|
|||
|
yield return null; // <20>ȴ<EFBFBD>һ֡
|
|||
|
}
|
|||
|
|
|||
|
SetText.text = endValue.ToString();
|
|||
|
|
|||
|
}
|
|||
|
// Update is called once per frame
|
|||
|
void Update()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
}
|