Test UniRx 01
Unity3D/UniRX 2019. 1. 18. 11:51반응형
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | using UnityEngine; using UniRx; using UniRx.Triggers; using System.Threading.Tasks; using System; public class TestInputMain : MonoBehaviour { public UIButton btnLeft; public UIButton btnRight; private float elapsedTime; void Start() { //확장메서드 var unit = this.UpdateAsObservable().Subscribe(_ => { elapsedTime += Time.deltaTime; Debug.Log($"Update: {Time.timeSinceLevelLoad}, {elapsedTime}"); }); Debug.Log($"unit: <color=red>{unit}</color>"); this.WaitAndDespose(() => { unit.Dispose(); Debug.Log($"unit: <color=red>unit disposed! : {Time.timeSinceLevelLoad}, {elapsedTime}</color>"); }); } private async void WaitAndDespose(System.Action onComplete) { await Task.Delay(TimeSpan.FromSeconds(1)); Debug.Log("1초대기"); await Observable.Timer(TimeSpan.FromSeconds(1)); Debug.Log("1초대기"); onComplete(); } } | cs |
반응형
'Unity3D > UniRX' 카테고리의 다른 글
Test UniRx 00 (0) | 2019.01.18 |
---|