IEnumerator LerpByTime(float duration)
{
bar.fillAmount = 0;
float currentAmount = bar.fillAmount;
float t =0;
while (t < 1)
{
t += Time.deltaTime / duration;
bar.fillAmount = Mathf.Lerp(currentAmount, 1, t);
yield return null;
}
}
自己稍微改下代码,可以用在任意地方