From ced8ed068f898c6bffd7e1f85f40f58e88e3cbb8 Mon Sep 17 00:00:00 2001 From: Colin Nickerson Date: Wed, 8 Jun 2016 08:37:55 -0300 Subject: [PATCH 1/2] Changing EnsureComponent to use Component rather than MonoBehaviour. --- MVVM/Views/Bindings/ViewBindings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVVM/Views/Bindings/ViewBindings.cs b/MVVM/Views/Bindings/ViewBindings.cs index 9444a70c..98593d9c 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(); From c7f034ea7314476fba4100964ec295c0c28e2319 Mon Sep 17 00:00:00 2001 From: Colin Nickerson Date: Wed, 8 Jun 2016 08:45:05 -0300 Subject: [PATCH 2/2] Fixing a fairly severe bug where onlyWhenChanged bindings would frequenty fail their equality test --- MVVM/Views/Bindings/ViewBindings.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MVVM/Views/Bindings/ViewBindings.cs b/MVVM/Views/Bindings/ViewBindings.cs index 98593d9c..fcf20ac3 100644 --- a/MVVM/Views/Bindings/ViewBindings.cs +++ b/MVVM/Views/Bindings/ViewBindings.cs @@ -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));