jbruening / ugui-mvvm

Unity3D uGUI mvvm databinding via the standard IXChanged interfaces used in wpf (INotifyPropertyChanged, INotifyCollectionChanged, etc)
Other
214 stars 41 forks source link

Add better support for "view to view" bindings #33

Closed ryantrem closed 5 years ago

ryantrem commented 5 years ago

This change makes source bindings and target bindings nearly identical. This means two things:

  1. Source bindings can trigger an update to the target based on a UnityEventBase.
  2. Target bindings can trigger an update to the source based on a PropertyChanged.

Previously, the source of bindings was processed by PropertyBinding.FigureBindings (for INotifyPropertyChanged) and the target of bindings was processed by PropertyBindingEditor.FigureViewBindings (for UnityEventBase). Now, both source and target bindings are processed in both ways (but only one will take affect, depending on how the binding has been configured).

Here is how this shows up in the editor for a pure view-to-view binding: image

In the case where a source or target of the binding is both a MonoBehaviour with one or more UnityEventBase and implements INotifyPropertyChanged, then both options show up: image

In the case where the source or target of the binding is a MonoBehaviour that implements INotifyPropertyChanged and has exposes no UnityEventBase members, then PropertyChanged is the only option and so no option is shown (PropertyChanged is automatically selected since it is the only choice). This is to make the common case super simple. image

In both cases (source and target), the dropdown only shows up if the binding mode indicates that the source or target can trigger an update.

@ritijain