반응형
- 코드 작성
using System.Collections;
using System.Collections.Generic;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class TimerUniRX : MonoBehaviour
{
public Text timerText;
private int timerIndex = 0;
private void Start()
{
Observable.Timer(System.TimeSpan.FromSeconds(1))
.Repeat()
.Subscribe(_ => UpdateTimer());
}
void UpdateTimer()
{
timerIndex++;
timerText.text = timerIndex.ToString();
}
}
참고할만한 글
반응형