반응형
- 코드 작성
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;
}
}
반응형
'개발 > C#' 카테고리의 다른 글
C# BFS (너비 우선 탐색) 알고리즘 예시 간단 구현 (0) | 2023.10.20 |
---|---|
C# 그리디 알고리즘 (Greedy 탐욕) 예시 간단 구현 (0) | 2023.10.20 |
C# 버블, 선택, 삽입, 퀵 정렬 예시 간단 구현 (0) | 2023.10.20 |
유니티 C# 출석체크 7일 간단 구현 Unity Attendance (0) | 2023.10.16 |
유니티 C# Byte[] To String PlayerPrefs 저장 불러오기 간단 구현 (0) | 2023.08.30 |
유니티 C# 슬롯머신 간단 구현 Unity Slot machine (0) | 2023.08.17 |
유니티 C# 캐릭터 주변 원 운동 오브젝트 간단 구현 및 데미지 주기 (0) | 2023.08.17 |
유니티 C# 맵 상에 직선 궤적 그리기 간단 구현 Line Renderer (0) | 2023.08.13 |
댓글