-
Notifications
You must be signed in to change notification settings - Fork 82
UnityWeld.Binding
Base class for binders to Unity MonoBehaviours.
public abstract class UnityWeld.Binding.AbstractMemberBinding
: MonoBehaviour, IMemberBinding
Methods
Type | Name | Summary |
---|---|---|
void |
Awake() | |
void |
Connect() | Connect to all the attached view models |
void |
Disconnect() | Disconnect from all attached view models. |
void |
Init() | Initialise this binding. Used when we first start the scene. Detaches any attached view models, finds available view models afresh and then connects the binding. |
PropertyEndPoint |
MakeViewModelEndPoint(String viewModelPropertyName, String adapterTypeName, AdapterOptions adapterOptions) |
Make a property end point for a property on the view model. |
void |
OnDestroy() | Clean up when the game object is destroyed. |
void |
ParseViewEndPointReference(String endPointReference, String& memberName, Component& view) |
Parse an end-point reference and get the component for the view. |
void |
ParseViewModelEndPointReference(String endPointReference, String& memberName, Object& viewModel) |
Parse an end-point reference and search up the hierarchy for the named view-model. |
Static Methods
Type | Name | Summary |
---|---|---|
IAdapter |
CreateAdapter(String adapterTypeName) |
Find the type of the adapter with the specified name and create it. |
void |
ParseEndPointReference(String endPointReference, String& memberName, String& typeName) |
Parse an end-point reference including a type name and member name separated by a period. |
public abstract class UnityWeld.Binding.AbstractTemplateSelector
: AbstractMemberBinding, IMemberBinding
Fields
Type | Name | Summary |
---|---|---|
Object |
viewModel | The view-model, cached during connection. |
PropertyWatcher |
viewModelPropertyWatcher | Watches the view-model property for changes. |
Properties
Type | Name | Summary |
---|---|---|
GameObject |
TemplatesRoot | The GameObject in the scene that is the parent object for the tenplates. |
String |
ViewModelPropertyName | The name of the property we are binding to on the view model. |
Methods
Type | Name | Summary |
---|---|---|
void |
DestroyAllTemplates() | Destroys all instantiated templates. |
void |
DestroyTemplate(Object viewModelToDestroy) |
Destroys the instantiated template associated with the provided object. |
void |
InstantiateTemplate(Object templateViewModel, Int32 index = 0) |
Create a clone of the template object and bind it to the specified view model. Place the new object under the parent at the specified index, or 0 if no index is specified. |
Attribute that defines what types an adapter can convert from and to.
public class UnityWeld.Binding.AdapterAttribute
: Attribute, _Attribute
Properties
Type | Name | Summary |
---|---|---|
Type |
InputType | |
Type |
OptionsType | |
Type |
OutputType |
Base class for adapter options.
public abstract class UnityWeld.Binding.AdapterOptions
: ScriptableObject
Bind a property in the view model to a parameter in an Animator, subscribing to OnPropertyChanged and updating the Animator parameter accordingly (note that this does not update the view model when the parameter changes).
public class UnityWeld.Binding.AnimatorParameterBinding
: AbstractMemberBinding, IMemberBinding
Properties
Type | Name | Summary |
---|---|---|
String |
AnimatorParameterName | Parameter name on the Animator |
AnimatorControllerParameterType |
AnimatorParameterType | The parameter type that we are binding to |
Boolean |
BoolParameter | |
Single |
FloatParameter | |
Int32 |
IntParameter | |
Boolean |
TriggerParameter | |
AdapterOptions |
ViewAdapterOptions | Options for adapting from the view model to the UI property. |
String |
ViewAdapterTypeName | Type of the adapter we're using to adapt between the view model property and UI property. |
String |
ViewModelPropertyName | Name of the property in the view model to bind. |
Methods
Type | Name | Summary |
---|---|---|
void |
Connect() | |
void |
Disconnect() |
public class UnityWeld.Binding.AnimatorParameterTrigger
: INotifyPropertyChanged
Properties
Type | Name | Summary |
---|---|---|
Boolean |
TriggerSetOrReset |
Events
Type | Name | Summary |
---|---|---|
PropertyChangedEventHandler |
PropertyChanged |
Methods
Type | Name | Summary |
---|---|---|
void |
OnPropertyChanged(String propertyName) |
|
void |
Reset() | |
void |
Set() |
Mark a class, interface, method or property as bindable. Bindable methods and properties must reside within classes or interfaces that have also been marked as bindable.
public class UnityWeld.Binding.BindingAttribute
: Attribute, _Attribute
An observable list that is bound to source list.
public class UnityWeld.Binding.BoundObservableList<DestT, SourceT>
: ObservableList<DestT>, IList<DestT>, ICollection<DestT>, IEnumerable<DestT>, IEnumerable, INotifyCollectionChanged, ITypedList, IList, ICollection, IDisposable
Methods
Type | Name | Summary |
---|---|---|
void |
Dispose() | |
void |
Dispose(Boolean disposing) |
Binds a property in the view-model that is a collection and instantiates copies of template objects to bind to the items of the collection. Creates and destroys child objects when items are added and removed from a collection that implements INotifyCollectionChanged, like ObservableList.
public class UnityWeld.Binding.CollectionBinding
: AbstractTemplateSelector, IMemberBinding
Methods
Type | Name | Summary |
---|---|---|
void |
Connect() | |
void |
Disconnect() |
public class UnityWeld.Binding.DropdownBinding
: AbstractMemberBinding, IMemberBinding
Fields
Type | Name | Summary |
---|---|---|
String |
exceptionAdapterTypeName | Adapter to apply to any adapter/validation exception that is assigned to the view model. |
String |
exceptionPropertyName | The name of the property to assign an exception to when adapter/validation fails. |
String |
optionsAdapter | Adapter for converting the options list in the view model to the correct format to display in the UI. |
String |
selectionUIToViewModelAdapter | Type name of the adapter for converting a selection value in the UI back to the type needed by the view model. |
String |
selectionViewModelToUIAdapter | Type name of the adapter for converting a selection value in the view model to what the UI expects (which should be a string). |
String |
viewModelOptionsPropertyName | Name of the property in the view model to bind for the list of options. |
String |
viewModelSelectionPropertyName | Name of the property in the view model to bind for the current selection. |
Properties
Type | Name | Summary |
---|---|---|
String[] |
Options | String of all the text options in the dropdown. |
String |
SelectedOption | String of the text of the currently selected option. |
Methods
Type | Name | Summary |
---|---|---|
void |
Connect() | |
void |
Disconnect() |
Class for binding Unity UI events to methods in a view model.
public class UnityWeld.Binding.EventBinding
: AbstractMemberBinding, IMemberBinding
Properties
Type | Name | Summary |
---|---|---|
String |
ViewEventName | Name of the event in the view to bind to. |
String |
ViewModelMethodName | Name of the method in the view model to bind to. |
Methods
Type | Name | Summary |
---|---|---|
void |
Connect() | |
void |
Disconnect() |
Base interface for all adapters. Combine with AdapterAttribute to specify the types it supports converting to and from.
public interface UnityWeld.Binding.IAdapter
Methods
Type | Name | Summary |
---|---|---|
Object |
Convert(Object valueIn, AdapterOptions options) |
Convert from the source type to the output type. This should throw an exception if the conversion fails or the input isn't valid. |
public interface UnityWeld.Binding.IMemberBinding
Methods
Type | Name | Summary |
---|---|---|
void |
Connect() | |
void |
Disconnect() | |
void |
Init() |
Interface for classes that generate collection changed events.
public interface UnityWeld.Binding.INotifyCollectionChanged
Events
Type | Name | Summary |
---|---|---|
EventHandler<NotifyCollectionChangedEventArgs> |
CollectionChanged | Event raised when the collection has been changed. |
Template for use in collection bindings.
public interface UnityWeld.Binding.ITemplate
Methods
Type | Name | Summary |
---|---|---|
void |
InitChildBindings(Object viewModel) |
Set the view model and initialise all binding objects down the hierarchy. |
A list that exposes the type of its items as a property.
public interface UnityWeld.Binding.ITypedList
: IList, ICollection, IEnumerable
Properties
Type | Name | Summary |
---|---|---|
Type |
ItemType | Specifies the type of items in the list. |
Interface for wiring view-models into the hierarchy.
public interface UnityWeld.Binding.IViewModelProvider
Methods
Type | Name | Summary |
---|---|---|
Object |
GetViewModel() | Get the view-model provided by this provider. |
String |
GetViewModelTypeName() | Get the name of the view-model's type. |
public static class UnityWeld.Binding.LinqExts
Static Methods
Type | Name | Summary |
---|---|---|
ObservableList<T> |
ObservableListFromItems(T[] items) |
|
ObservableList<T> |
ToObservableList(this IEnumerable<T> source) |
public enum UnityWeld.Binding.NotifyCollectionChangedAction
: Enum, IComparable, IFormattable, IConvertible
Enum
Value | Name | Summary |
---|---|---|
0 |
Add | |
1 |
Remove | |
2 |
Reset |
Arguments for collection changed event.
public class UnityWeld.Binding.NotifyCollectionChangedEventArgs
: EventArgs
Properties
Type | Name | Summary |
---|---|---|
NotifyCollectionChangedAction |
Action | Gets the action that caused the event. Returns: A System.Collections.Specialized.NotifyCollectionChangedAction value that describes the action that caused the event. |
IList |
NewItems | Gets the list of new items involved in the change. Returns: The list of new items involved in the change. |
Int32 |
NewStartingIndex | Gets the index at which the change occurred. Returns: The zero-based index at which the change occurred. |
IList |
OldItems | Gets the list of items affected by a System.Collections.Specialized.NotifyCollectionChangedAction.Replace, Remove, or Move action. Returns: The list of items affected by a System.Collections.Specialized.NotifyCollectionChangedAction.Replace, Remove, or Move action. |
Int32 |
OldStartingIndex | Gets the index at which a System.Collections.Specialized.NotifyCollectionChangedAction.Move, Remove, or Replace action occurred. Returns: The zero-based index at which a System.Collections.Specialized.NotifyCollectionChangedAction.Move, Remove, or Replace action occurred. |
Static Methods
Type | Name | Summary |
---|---|---|
NotifyCollectionChangedEventArgs |
ItemAdded(Object item, Int32 index) |
|
NotifyCollectionChangedEventArgs |
ItemRemoved(Object item, Int32 index) |
|
NotifyCollectionChangedEventArgs |
Reset(Object[] items) |
public class UnityWeld.Binding.ObservableList<T>
: IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, INotifyCollectionChanged, ITypedList, IList, ICollection
Properties
Type | Name | Summary |
---|---|---|
Int32 |
Count | |
Boolean |
IsFixedSize | |
Boolean |
IsReadOnly | |
Boolean |
IsSynchronized | |
T |
Item | |
Type |
ItemType | Specifies the type of items in the list. |
Object |
SyncRoot |
Events
Type | Name | Summary |
---|---|---|
EventHandler<NotifyCollectionChangedEventArgs> |
CollectionChanged | Event raised when the collection has been changed. |
Methods
Type | Name | Summary |
---|---|---|
void |
Add(T item) |
|
Int32 |
Add(Object item) |
|
void |
Clear() | |
Boolean |
Contains(T item) |
|
Boolean |
Contains(Object item) |
|
void |
CopyTo(T[] array, Int32 arrayIndex) |
|
void |
CopyTo(Array array, Int32 index) |
|
IEnumerator<T> |
GetEnumerator() | |
Int32 |
IndexOf(T item) |
|
Int32 |
IndexOf(Object item) |
|
void |
Insert(Int32 index, T item) |
|
void |
Insert(Int32 index, Object item) |
|
Boolean |
Remove(T item) |
|
void |
Remove(Object item) |
|
void |
RemoveAt(Int32 index) |
Bind a property in the view model to one on the UI, subscribing to OnPropertyChanged and updating the UI accordingly (note that this does not update the view model when the UI changes).
public class UnityWeld.Binding.OneWayPropertyBinding
: AbstractMemberBinding, IMemberBinding
Properties
Type | Name | Summary |
---|---|---|
AdapterOptions |
ViewAdapterOptions | Options for adapting from the view model to the UI property. |
String |
ViewAdapterTypeName | Type of the adapter we're using to adapt between the view model property and UI property. |
String |
ViewModelPropertyName | Name of the property in the view model to bind. |
String |
ViewPropertyName | Property on the view to update when value changes. |
Methods
Type | Name | Summary |
---|---|---|
void |
Connect() | |
void |
Disconnect() |
Bind a sub-view model which is a property on another view model for use in the UI.
public class UnityWeld.Binding.SubViewModelBinding
: AbstractMemberBinding, IMemberBinding, IViewModelProvider
Properties
Type | Name | Summary |
---|---|---|
String |
ViewModelPropertyName | Name of the property in the view-model that contains the sub-viewmodel. |
String |
ViewModelTypeName | Name of the type of the view model we're binding to. Set from the Unity inspector. |
Methods
Type | Name | Summary |
---|---|---|
void |
Connect() | |
void |
Disconnect() | |
Object |
GetViewModel() | Get the view-model provided by this provider. |
String |
GetViewModelTypeName() | Get the name of the view-model's type. |
Template for use in collection bindings.
public class UnityWeld.Binding.Template
: MonoBehaviour, IViewModelProvider, ITemplate
Properties
Type | Name | Summary |
---|---|---|
String |
ViewModelTypeName |
Methods
Type | Name | Summary |
---|---|---|
Object |
GetViewModel() | Get the view-model provided by this provider. |
String |
GetViewModelTypeName() | Get the name of the view-model's type. |
void |
InitChildBindings(Object viewModel) |
Set the view model and initialise all binding objects down the hierarchy. |
Binds to a view and instantiates a template based on the view type.
public class UnityWeld.Binding.TemplateBinding
: AbstractTemplateSelector, IMemberBinding
Methods
Type | Name | Summary |
---|---|---|
void |
Connect() | Connect to the attached view model. |
void |
Disconnect() | Disconnect from the attached view model. |
Bind to a boolean property on the view model and turn all child objects on or off based on its value.
public class UnityWeld.Binding.ToggleActiveBinding
: AbstractMemberBinding, IMemberBinding
Properties
Type | Name | Summary |
---|---|---|
Boolean |
ChildrenActive | Preoprty for the propertySync to set in order to activate and deactivate all children |
AdapterOptions |
ViewAdapterOptions | Options for adapting from the view model to the view property. |
String |
ViewAdapterTypeName | Type of the adapter we're using to adapt between the view model property and view property. |
String |
ViewModelPropertyName | Name of the property in the view model to bind. |
Methods
Type | Name | Summary |
---|---|---|
void |
Connect() | |
void |
Disconnect() |
Bind a property in the view model to one the UI, subscribing to OnPropertyChanged and updating the UI accordingly. Also bind to a UnityEvent in the UI and update the view model when the event is triggered.
public class UnityWeld.Binding.TwoWayPropertyBinding
: AbstractMemberBinding, IMemberBinding
Properties
Type | Name | Summary |
---|---|---|
AdapterOptions |
ExceptionAdapterOptions | Adapter options for an exception. |
String |
ExceptionAdapterTypeName | Adapter to apply to any adapter/validation exception that is assigned to the view model. |
String |
ExceptionPropertyName | The name of the property to assign an exception to when adapter/validation fails. |
AdapterOptions |
ViewAdapterOptions | Options for the adapter from the view model to the view. |
String |
ViewAdapterTypeName | Name of the type of the adapter we're using to convert values from the view model to the view. Can be empty for no adapter. |
String |
ViewEventName | Event in the view to bind to. |
AdapterOptions |
ViewModelAdapterOptions | Options for the adapter from the view to the view model. |
String |
ViewModelAdapterTypeName | Name of the type of the adapter we're using to conver values from the view back to the view model. Can be empty for no adapter. |
String |
ViewModelPropertyName | Name of the property in the view model to bind. |
String |
ViewPropertName | Property on the view to update when value changes. |
Methods
Type | Name | Summary |
---|---|---|
void |
Connect() | |
void |
Disconnect() |