Unity中实现在规定时间内从一个值递增到另一个值

2021-08-17 19:59

阅读:741

标签:text   play   ogr   指定   实现   closed   执行   图片   数据   1、进度条(在规定时间内完成进度条) private Image progressBar; private float currentProgress = 0; /// /// 进度条需要持续的时长 /// private float duration = 5f;//这个时间可以任意定义 private void ProgressBar() { currentProgress += Time.deltaTime; progressBar.fillAmount = currentProgress / duration; if (currentProgress >= duration) { progressBar.fillAmount = 1; } } View Code   2、数值递增(在规定时间内从0递增到115) private Text showText;//展示的Text private float time = 5f;//指定的时间 private float currentVaule = 0f;//起始值 private float targetVaule = 115f;//目标值 /// /// 数据递增 /// public void DataIncrement() { currentVaule += Time.deltaTime * (targetVaule / time); if (currentVaule


评论


亲,登录后才可以留言!