Example #1
0
        public static IDisposable BindSliderToHandler(this ViewBase viewBase, Slider slider, Action <float> handler)
        {
            var d = slider.AsValueChangedObservable().Subscribe(value =>
            {
                handler(value);
            }).DisposeWith(viewBase);

            return(d);
        }
Example #2
0
    public static IDisposable BindSliderToProperty(this ViewBase viewBase, Slider slider, P <float> property)
    {
        var d1 = slider.AsValueChangedObservable().Subscribe(value =>
        {
            property.OnNext(value);
        }).DisposeWith(viewBase);

        var d2 = property.Subscribe(value =>
        {
            slider.value = value;
        });

        return(Disposable.Create(() =>
        {
            d1.Dispose();
            d2.Dispose();
        }).DisposeWith(viewBase));
    }
Example #3
0
    public static IDisposable BindSliderToProperty <TO>(this ViewBase viewBase, Slider slider, P <TO> property, Func <float, TO> i2pSelector, Func <TO, float> p2iSelector)
    {
        var d1 = slider.AsValueChangedObservable().Subscribe(value =>
        {
            property.OnNext(i2pSelector(value));
        });

        var d2 = property.Subscribe(value =>
        {
            slider.value = p2iSelector(value);
        });

        return(Disposable.Create(() =>
        {
            d1.Dispose();
            d2.Dispose();
        }).DisposeWith(viewBase));
    }
Example #4
0
        public static IDisposable BindSliderToProperty(this ViewBase viewBase, Slider slider, P <float> property)
        {
            //Debug.Log("seeting slider to "+property.Value);
            //slider.value = property.Value;

            var d1 = slider.AsValueChangedObservable().Subscribe(value =>
            {
                property.OnNext(value);
            }).DisposeWith(viewBase);

            var d2 = property.Subscribe(value =>
            {
                slider.value = value;
            });

            Observable.EveryEndOfFrame().Take(1).Subscribe(_ => slider.value = property.Value);


            return(Disposable.Create(() =>
            {
                d1.Dispose();
                d2.Dispose();
            }).DisposeWith(viewBase));
        }