Last active
August 29, 2015 14:16
-
-
Save hacha/bc6791e7bfa7aaf20a11 to your computer and use it in GitHub Desktop.
生成されて10秒後に消滅するボール、みたいなものをUniRxで記述したもの
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System; | |
using UniRx; | |
public class Ball : MonoBehaviour | |
{ | |
void Awake () | |
{ | |
// var stream = Observable | |
// .EveryUpdate () | |
// .Delay(TimeSpan.FromSeconds(10)) | |
// .Take (1) | |
// ; | |
// var subscription = stream.Subscribe( _ => Destroy(gameObject) ); | |
// stream.Subscribe(_ => subscription.Dispose() ); | |
// 削除しちゃうなら別に明示的にDispose()しなくてよかったみたい。 | |
// なので下記になった。シンプル | |
Observable.Timer(TimeSpan.FromSeconds(10)).Subscribe( _ => Destroy(gameObject) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
なるほど、Timerそのものが残ってたってことなんですね!