Skip to main content

Misc Binders

Binders that do not belong to a specific UI component category.


ObjectNameBinder

Binds the object name, Object.name.

InterfaceDescription
IBinder<string>Sets the name
IReverseBinder<string>Sends the current name (OneWayToSource)

Inspector properties

PropertyDescription
ConverterIConverter<string?, string?> (optional)

Modes: OneWay, OneTime, OneWayToSource (TwoWay is not allowed).

[ViewModel]
public partial class ItemViewModel
{
[OneWayBind] private string _itemName;
// ObjectNameBinder sets gameObject.name = itemName
}

ComponentToSourceMonoBinder<T>

The base MonoBinder for sending a component from the View to the ViewModel. On bind it sends the component reference through IReverseBinder<TComponent>.

Used to pass Unity components into the ViewModel:

[ViewModel]
public partial class PlayerViewModel
{
[OneWayToSourceBind] private Rigidbody _rigidbody;
}
// In the View a ComponentToSourceMonoBinder<Rigidbody> binds to the field

Ready-made specializations

ClassComponent
SliderToSourceMonoBinderSlider
DropdownToSourceMonoBinderTMP_Dropdown
AudioSourceToSourceMonoBinderAudioSource
RendererToSourceMonoBinderRenderer
RectTransformToSourceMonoBinderRectTransform

The universal ComponentToSourceMonoBinder

The untyped variant sends the Component as object through IAnyReverseBinder. Fits any component.

Mode: OneWayToSource only.


ByBindMonoBinder

The "bind by binder" pattern: MonoBinder wrappers that drive a target component on another GameObject. Examples:

ClassDescription
GameObjectVisibleByBindMonoBinderShows/hides the given GameObject

See also