diff --git a/MVVM/Views/Bindings/ViewBindings.cs b/MVVM/Views/Bindings/ViewBindings.cs index 9444a70c..fcf20ac3 100644 --- a/MVVM/Views/Bindings/ViewBindings.cs +++ b/MVVM/Views/Bindings/ViewBindings.cs @@ -216,7 +216,7 @@ public static IObservable OnTrigger2DObservable(this GameObject t, C /// /// /// - public static T EnsureComponent(this GameObject t) where T : MonoBehaviour + public static T EnsureComponent(this GameObject t) where T : Component { if (t.GetComponent() != null) return t.GetComponent(); return t.AddComponent(); @@ -401,7 +401,7 @@ public static IDisposable DisposeWhenChanged(this IDisposable disposable, P sourceProperty.LastValue != sourceProperty.ObjectValue) + sourceProperty.Where(p => Object.Equals(sourceProperty.LastValue, sourceProperty.ObjectValue) == false) .First() .Subscribe(_ => { disposable.Dispose(); }); return d; @@ -426,8 +426,8 @@ public static IDisposable BindProperty(this IBindable bindable, P< if (onlyWhenChanged) { return - bindable.AddBinding( - property.Where(p => property.LastValue != property.ObjectValue).Subscribe(changed)); + bindable.AddBinding( + property.Where(p => Object.Equals(property.LastValue, property.ObjectValue) == false).Subscribe(changed)); } return bindable.AddBinding(property.Subscribe(changed)); @@ -450,7 +450,7 @@ public static IDisposable BindTwoWay(this IBindable bindable, P property.LastValue != property.ObjectValue).Subscribe(changed)); + property.Where(p => Object.Equals(property.LastValue, property.ObjectValue) == false).Subscribe(changed)); } return bindable.AddBinding(property.Subscribe(changed));