반응형
- 코드 작성
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Example : MonoBehaviour
{
public Text timerText;
public int timer = 0;
private void Start()
{
StartCoroutine(TimerCoroution());
}
IEnumerator TimerCoroution()
{
timer += 1;
timerText.text = (timer / 3600).ToString("D2") + ":" + (timer / 60 % 60).ToString("D2") + ":" + (timer % 60).ToString("D2");
yield return new WaitForSeconds(1f);
StartCoroutine(TimerCoroution());
}
}
참고할만한 글
반응형
'개발 > C#' 카테고리의 다른 글
유니티 C# 조건문 if, else, Swtich 문 간단 사용법 (0) | 2022.06.30 |
---|---|
유니티 C# Application 관련 API 사용법 모음 (0) | 2022.06.21 |
유니티 C# 이벤트 델리게이트 delegate Event 간단 사용법 (0) | 2022.06.21 |
유니티 C# 로컬 데이터 저장, 불러오기 PlayerPrefs 간단 사용법 (0) | 2022.06.21 |
유니티 C# 충돌 처리 OnTrigger Enter, Stay, Exit 간단 사용법 (0) | 2022.06.21 |
유니티 C# 코루틴 동작, 시간 딜레이 Coroutine, Invoke 간단 사용법 (0) | 2022.06.21 |
유니티 C# 씬 로드 동기, 비동기 간단 사용법 Load Scene Async (0) | 2022.06.21 |
유니티 C# 랜덤 난수 생성 Random.Range 간단 사용법 (0) | 2022.06.21 |
댓글