Esempio n. 1
0
    public static IDisposable BindInputFieldToHandler(this ViewBase viewBase, InputField inputField, Action <string> handler)
    {
        var d = inputField.AsValueChangedObservable().Subscribe(value =>
        {
            handler(value);
        }).DisposeWith(viewBase);

        return(d);
    }
Esempio n. 2
0
    public static IDisposable BindInputFieldToProperty(this ViewBase viewBase, InputField inputField, P <string> property)
    {
        var d1 = inputField.AsValueChangedObservable().Subscribe(value =>
        {
            property.OnNext(value);
        }).DisposeWith(viewBase);

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

        return(Disposable.Create(() =>
        {
            d1.Dispose();
            d2.Dispose();
        }).DisposeWith(viewBase));
    }
Esempio n. 3
0
    public static IDisposable BindInputFieldToProperty <TO>(this ViewBase viewBase, InputField inputField, P <TO> property, Func <string, TO> i2pSelector, Func <TO, string> p2iSelector)
    {
        var d1 = inputField.AsValueChangedObservable().Subscribe(value =>
        {
            property.OnNext(i2pSelector(value));
        });

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

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