반응형
- 코드 작성
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class FillAmountChange : MonoBehaviour
{
public Image image;
public float duration = 30.0f;
private void Start()
{
StartCoroutine(ChangeFillAmountOverTime());
}
private IEnumerator ChangeFillAmountOverTime()
{
float currentTime = 0.0f;
float startFillAmount = 1.0f;
float endFillAmount = 0.0f;
while (currentTime < duration)
{
float fillAmount = Mathf.Lerp(startFillAmount, endFillAmount, currentTime / duration);
fillAmount = Mathf.Clamp01(fillAmount);
image.fillAmount = fillAmount;
currentTime += Time.deltaTime;
yield return null;
}
image.fillAmount = endFillAmount;
}
}
반응형