반응형
- 코드 작성
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());
}
}
참고할만한 글
반응형