using UnityEngine;
using UnityEngine.UI;
class ScoreTest: MonoBehaviour
{
int currentScore;//当前分
Text txt_Score;//分数显示文本
void Start
{
txt_Score = transform.GetComponent<Text>();
}
void ShowScore(int score)// score 为玩家分数
{
if (score == 0)
{
currentScore = 0;
txt_Score.text = 0;
}
if (AddTime <= 0.005f)//间隔时间增加
{
AddTime += Time.deltaTime;
}
else {
if (currentScore < score)//未增加到玩家分数值就一直加
{
currentScore++;
txt_Score.text = "$" + currentScore;
AddTime = 0;
if (10 < score - currentScore) currentScore += 10; //分数相差太大时,将累加量调高改善分数显示延后太多的问
}
}
}
}
unity 分数动态增加
最新推荐文章于 2023-08-11 08:19:41 发布