Edited at

UniRx 書き方サンプルメモ

More than 1 year has passed since last update.


ReactiveStringの変化購読

ReactiveString.Where(value => value == Co.MODE_STOP).Subscribe( value => {

//stringが変更された時の処理
});


ReactiveCollectionの初期化

ReactiveCollection<bool> reactiveCollection = new ReactiveCollection<bool>(){true,false,false,false};


ReactiveCollectionのネスト


宣言

private ReactiveCollection<bool> collection;

public ReactiveCollection<ReactiveCollection<bool>> collections;


初期化

collection = new ReactiveCollection<bool>(){true,false,false,false,true,false,false,false,true,false,false,false,true,false,false,true};

collections = new ReactiveCollection<ReactiveCollection<bool>>(){Sequence};


KeyEventのReactive化


Stream

IObservable<bool>  keydownStream = this.UpdateAsObservable().ObserveEveryValueChanged(_ => Input.GetKeyDown(keycode)).Where(x => x);



Subscribe

keydownStream.Subscribe(_ => Debug.Log("KeyDown"));



購読の停止

.Subscribe の戻り値がIDisposable .Dispose();で購読停止可能。

追記していきます。