public static List <IInputObservable> Setup(InputObservableContext context, DrawTargetView draw, Component component) { var ios = new List <IInputObservable>(); if (draw == null || component == null) { return(ios); } var colors = new List <Color> { Color.green, Color.yellow, Color.red, Color.blue, Color.black }; foreach (var(index, color) in colors.Select((color, index) => (index, color))) { try { var io = context.GetObservable(index); io.Any().Subscribe(touchDrawHandler(draw, color)).AddTo(component); ios.Add(io); }catch (IndexOutOfRangeException e) { Debug.Log($"{e} ignore"); break; } } return(ios); }
void Start() { slider = FindObjectOfType <SliderController>(); slider.Text = "Interval: "; draw = FindObjectOfType <DrawTargetView>(); context = this.DefaultInputContext(); context.GetObservable(0).OnBegin.TimeInterval().Subscribe(ts => { Debug.Log($"[{ts.Value.sequenceId}] {ts.Interval.Milliseconds}"); }).AddTo(this); slider.Enabled.Subscribe(v => { if (!v) { clear(); } else { setup(); } }).AddTo(this); slider.Value.Subscribe(v => setup()).AddTo(this); }
public MouseInputObservable(InputObservableContext context, int buttonId) : base(context) { this.buttonId = buttonId; }