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();で購読停止可能。
ReactiveEnum を自分で定義して State 管理
State
public class StateManager : MonoBehaviour
{
public StateReactiveProperty appState = new StateReactiveProperty(APP_STATE.WAITING);
public enum APP_STATE
{
WAITING = 0,
PLAY,
COUNT_DOWN,
FINISH
}
// Start is called before the first frame update
void Start()
{
appState.Subscribe(value =>
{
Debug.Log("APP_STATE:" + value);
});
}
}
[System.Serializable]
public class StateReactiveProperty : ReactiveProperty<StateManager.APP_STATE>
{
public StateReactiveProperty() { }
public StateReactiveProperty(StateManager.APP_STATE initialValue) : base(initialValue) { }
}
追記していきます。