Table of Contents

Class BindContext

Namespace
Bindables
Assembly
Bindables.dll

Provides a context for managing the lifetime of bindings between bindable objects and their listeners. Automatically unbinds all registered listeners when the context becomes invalid or is explicitly unbound.

public class BindContext
Inheritance
BindContext
Inherited Members
Extension Methods

Constructors

BindContext()

Creates a BindContext that remains valid indefinitely. This context must be manually unbound when no longer needed.

public BindContext()

BindContext(Func<bool>)

Creates a BindContext with a custom validity check function.

public BindContext(Func<bool> isValid)

Parameters

isValid Func<bool>

A function that returns true if the context should remain valid, false otherwise.

BindContext(CancellationToken)

Creates a BindContext that remains valid until the cancellation token is cancelled.

public BindContext(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The cancellation token that determines the lifetime of this context.

BindContext(Object)

Creates a BindContext that remains valid as long as the specified Unity Object exists.

public BindContext(Object obj)

Parameters

obj Object

The Unity Object that determines the lifetime of this context.

BindContext(VisualElement)

Creates a BindContext that remains valid as long as the object is alive.

public BindContext(VisualElement element)

Parameters

element VisualElement

Properties

IsValid

Gets a value indicating whether this bind context is still valid and can accept new bindings. Returns false if the context has been unbound or if the validity check function returns false.

public bool IsValid { get; }

Property Value

bool

Methods

AddUnbindAction(Action)

Adds an action to be executed when this context is unbound.

public void AddUnbindAction(Action unbind)

Parameters

unbind Action

The action to execute during unbinding.

Exceptions

InvalidOperationException

Thrown if this context has already been unbound.

Bind(IBindable, IBindable, IBindable, IBindable, Action)

Binds to multiple bindable change events and immediately invokes the action. The action will be called immediately and whenever any of the bindables change.

public void Bind(IBindable bindable1, IBindable bindable2, IBindable bindable3, IBindable bindable4, Action action)

Parameters

bindable1 IBindable

The first bindable to subscribe to.

bindable2 IBindable

The second bindable to subscribe to.

bindable3 IBindable

The third bindable to subscribe to.

bindable4 IBindable

The fourth bindable to subscribe to.

action Action

The action to invoke immediately and on future changes.

Bind(IBindable, IBindable, IBindable, Action)

Binds to multiple bindable change events and immediately invokes the action. The action will be called immediately and whenever any of the bindables change.

public void Bind(IBindable bindable1, IBindable bindable2, IBindable bindable3, Action action)

Parameters

bindable1 IBindable

The first bindable to subscribe to.

bindable2 IBindable

The second bindable to subscribe to.

bindable3 IBindable

The third bindable to subscribe to.

action Action

The action to invoke immediately and on future changes.

Bind(IBindable, IBindable, Action)

Binds to multiple bindable change events and immediately invokes the action. The action will be called immediately and whenever any of the bindables change.

public void Bind(IBindable bindable1, IBindable bindable2, Action action)

Parameters

bindable1 IBindable

The first bindable to subscribe to.

bindable2 IBindable

The second bindable to subscribe to.

action Action

The action to invoke immediately and on future changes.

Bind(IBindable, Action)

Binds to a bindable change event and immediately invokes the action. The action will be called immediately and whenever the bindable changes.

public void Bind(IBindable bindable, Action action)

Parameters

bindable IBindable

The bindable to subscribe to.

action Action

The action to invoke immediately and on future changes.

BindAudioClipUri(IBindable<string>, AudioType, Action<AudioClip>)

Binds to a string URI and automatically downloads audio clips when the URI changes. Manages audio clip lifecycle, releasing previous clips when new ones are loaded.

public void BindAudioClipUri(IBindable<string> bindable, AudioType audioType = AudioType.UNKNOWN, Action<AudioClip> onLoad = null)

Parameters

bindable IBindable<string>

The bindable string containing the audio clip URI.

audioType AudioType

The type of audio format to expect. AudioType.UNKNOWN will auto-detect.

onLoad Action<AudioClip>

Optional callback invoked when an audio clip is successfully loaded.

BindDeferred(IBindable, IBindable, IBindable, IBindable, Action)

Binds to multiple bindable change events without immediately invoking the action. The action will be called whenever any of the bindables change.

public void BindDeferred(IBindable bindable1, IBindable bindable2, IBindable bindable3, IBindable bindable4, Action action)

Parameters

bindable1 IBindable

The first bindable to subscribe to.

bindable2 IBindable

The second bindable to subscribe to.

bindable3 IBindable

The third bindable to subscribe to.

bindable4 IBindable

The fourth bindable to subscribe to.

action Action

The action to invoke when any bindable changes.

BindDeferred(IBindable, IBindable, IBindable, Action)

Binds to multiple bindable change events without immediately invoking the action. The action will be called whenever any of the bindables change.

public void BindDeferred(IBindable bindable1, IBindable bindable2, IBindable bindable3, Action action)

Parameters

bindable1 IBindable

The first bindable to subscribe to.

bindable2 IBindable

The second bindable to subscribe to.

bindable3 IBindable

The third bindable to subscribe to.

action Action

The action to invoke when any bindable changes.

BindDeferred(IBindable, IBindable, Action)

Binds to multiple bindable change events without immediately invoking the action. The action will be called whenever any of the bindables change.

public void BindDeferred(IBindable bindable1, IBindable bindable2, Action action)

Parameters

bindable1 IBindable

The first bindable to subscribe to.

bindable2 IBindable

The second bindable to subscribe to.

action Action

The action to invoke when any bindable changes.

BindDeferred(IBindable, Action)

Binds to a bindable change event without immediately invoking the action. The action will be called whenever the bindable changes.

public void BindDeferred(IBindable bindable, Action action)

Parameters

bindable IBindable

The bindable to subscribe to.

action Action

The action to invoke when the bindable changes.

BindDeferred<T>(IBindable<T>, Action<T>)

Binds to a bindable value change event without immediately invoking the action. The action will be called whenever the bindable value changes.

public void BindDeferred<T>(IBindable<T> bindable, Action<T> action)

Parameters

bindable IBindable<T>

The bindable to subscribe to.

action Action<T>

The action to invoke when the value changes.

Type Parameters

T

The type of the bindable value.

BindDictionaryDeferred<TKey, TValue>(IBindableDictionary<TKey, TValue>, Action, Action<TKey, TValue>, Action<TKey, TValue, TValue>, Action<TKey, TValue>)

Binds to a bindable dictionary's change events without immediately invoking any callbacks. Allows monitoring of dictionary modifications including additions, changes, and removals.

public void BindDictionaryDeferred<TKey, TValue>(IBindableDictionary<TKey, TValue> dict, Action onChange = null, Action<TKey, TValue> onElementAdd = null, Action<TKey, TValue, TValue> onElementChange = null, Action<TKey, TValue> onElementRemove = null)

Parameters

dict IBindableDictionary<TKey, TValue>

The bindable dictionary to monitor.

onChange Action

Called when the dictionary changes in any way.

onElementAdd Action<TKey, TValue>

Called when an element is added to the dictionary.

onElementChange Action<TKey, TValue, TValue>

Called when an element value in the dictionary is changed.

onElementRemove Action<TKey, TValue>

Called when an element is removed from the dictionary.

Type Parameters

TKey

The type of keys in the dictionary.

TValue

The type of values in the dictionary.

BindDictionaryToCreateObjects<TKey, TValue, TObject>(IBindable<Dictionary<TKey, TValue>>, Func<TKey, TValue, TObject>, Action<TKey, TValue, TObject>)

Binds a dictionary to automatically create and destroy objects based on dictionary changes. Useful for dynamically managing objects that correspond to dictionary entries.

public void BindDictionaryToCreateObjects<TKey, TValue, TObject>(IBindable<Dictionary<TKey, TValue>> dict, Func<TKey, TValue, TObject> createObject, Action<TKey, TValue, TObject> destroyObject)

Parameters

dict IBindable<Dictionary<TKey, TValue>>

The bindable dictionary to monitor.

createObject Func<TKey, TValue, TObject>

Function to create an object for a dictionary entry.

destroyObject Action<TKey, TValue, TObject>

Action to destroy an object when its entry is removed.

Type Parameters

TKey

The type of keys in the dictionary.

TValue

The type of values in the dictionary.

TObject

The type of objects to create for each dictionary entry.

BindDictionaryToInstantiate<TKey, TValue>(IBindable<Dictionary<TKey, TValue>>, GameObject, Transform, Action<TKey, TValue, GameObject>)

Binds a dictionary to automatically instantiate and destroy GameObjects based on dictionary changes. Each dictionary entry will have a corresponding GameObject instantiated from the prefab.

public void BindDictionaryToInstantiate<TKey, TValue>(IBindable<Dictionary<TKey, TValue>> dict, GameObject prefab, Transform parent = null, Action<TKey, TValue, GameObject> onInstantiate = null)

Parameters

dict IBindable<Dictionary<TKey, TValue>>

The bindable dictionary to monitor.

prefab GameObject

The GameObject prefab to instantiate for each entry.

parent Transform

Optional parent transform for instantiated objects.

onInstantiate Action<TKey, TValue, GameObject>

Optional callback invoked when an object is instantiated.

Type Parameters

TKey

The type of keys in the dictionary.

TValue

The type of values in the dictionary.

BindDictionaryToInstantiate<TKey, TValue, TComponent>(IBindable<Dictionary<TKey, TValue>>, TComponent, Transform, Action<TKey, TValue, TComponent>)

Binds a dictionary to automatically instantiate and destroy Components based on dictionary changes. Each dictionary entry will have a corresponding Component instantiated from the prefab.

public void BindDictionaryToInstantiate<TKey, TValue, TComponent>(IBindable<Dictionary<TKey, TValue>> dict, TComponent prefab, Transform parent = null, Action<TKey, TValue, TComponent> onInstantiate = null) where TComponent : Component

Parameters

dict IBindable<Dictionary<TKey, TValue>>

The bindable dictionary to monitor.

prefab TComponent

The Component prefab to instantiate for each entry.

parent Transform

Optional parent transform for instantiated objects.

onInstantiate Action<TKey, TValue, TComponent>

Optional callback invoked when a component is instantiated.

Type Parameters

TKey

The type of keys in the dictionary.

TValue

The type of values in the dictionary.

TComponent

The type of Component to instantiate.

BindDictionary<TKey, TValue>(IBindableDictionary<TKey, TValue>, Action, Action<TKey, TValue>, Action<TKey, TValue, TValue>, Action<TKey, TValue>)

Binds to a bindable dictionary's change events and immediately invokes the onChange callback. Allows monitoring of dictionary modifications including additions, changes, and removals.

public void BindDictionary<TKey, TValue>(IBindableDictionary<TKey, TValue> dict, Action onChange = null, Action<TKey, TValue> onElementAdd = null, Action<TKey, TValue, TValue> onElementChange = null, Action<TKey, TValue> onElementRemove = null)

Parameters

dict IBindableDictionary<TKey, TValue>

The bindable dictionary to monitor.

onChange Action

Called immediately and when the dictionary changes in any way.

onElementAdd Action<TKey, TValue>

Called when an element is added to the dictionary.

onElementChange Action<TKey, TValue, TValue>

Called when an element value in the dictionary is changed.

onElementRemove Action<TKey, TValue>

Called when an element is removed from the dictionary.

Type Parameters

TKey

The type of keys in the dictionary.

TValue

The type of values in the dictionary.

BindEndOfFrame(Action, Func<bool>)

Binds an action to be called at the end of every Unity frame while the context is valid.

public void BindEndOfFrame(Action updateFunc, Func<bool> doneFunc = null)

Parameters

updateFunc Action

The action to call at the end of every frame.

doneFunc Func<bool>

Optional function that returns true when the update should stop.

BindEvent(UnityEvent, Action)

Binds to a UnityEvent with a synchronous action that will be called when the event is triggered.

public void BindEvent(UnityEvent evt, Action action)

Parameters

evt UnityEvent

The UnityEvent to subscribe to.

action Action

The action to invoke when the event is triggered.

BindEvent(UnityEvent, Func<Task>)

Binds to a UnityEvent with an async action that will be called when the event is triggered.

public void BindEvent(UnityEvent evt, Func<Task> action)

Parameters

evt UnityEvent

The UnityEvent to subscribe to.

action Func<Task>

The async action to invoke when the event is triggered.

BindEvent<T>(UnityEvent<T>, Action<T>)

Binds to a UnityEvent with a synchronous action that will be called when the event is triggered.

public void BindEvent<T>(UnityEvent<T> evt, Action<T> action)

Parameters

evt UnityEvent<T>

The UnityEvent to subscribe to.

action Action<T>

The action to invoke when the event is triggered.

Type Parameters

T

The type of the event parameter.

BindEvent<T>(UnityEvent<T>, Func<T, Task>)

Binds to a UnityEvent with an async action that will be called when the event is triggered.

public void BindEvent<T>(UnityEvent<T> evt, Func<T, Task> action)

Parameters

evt UnityEvent<T>

The UnityEvent to subscribe to.

action Func<T, Task>

The async action to invoke when the event is triggered.

Type Parameters

T

The type of the event parameter.

BindEvent<TEvent>(CallbackEventHandler, Action, TrickleDown)

public void BindEvent<TEvent>(CallbackEventHandler element, Action callback, TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) where TEvent : EventBase<TEvent>, new()

Parameters

element CallbackEventHandler
callback Action
useTrickleDown TrickleDown

Type Parameters

TEvent

BindEvent<TEvent>(CallbackEventHandler, EventCallback<TEvent>, TrickleDown)

public void BindEvent<TEvent>(CallbackEventHandler element, EventCallback<TEvent> callback, TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) where TEvent : EventBase<TEvent>, new()

Parameters

element CallbackEventHandler
callback EventCallback<TEvent>
useTrickleDown TrickleDown

Type Parameters

TEvent

BindEvent<T0, T1>(UnityEvent<T0, T1>, Action<T0, T1>)

Binds to a UnityEvent with a synchronous action that will be called when the event is triggered.

public void BindEvent<T0, T1>(UnityEvent<T0, T1> evt, Action<T0, T1> action)

Parameters

evt UnityEvent<T0, T1>

The UnityEvent to subscribe to.

action Action<T0, T1>

The action to invoke when the event is triggered.

Type Parameters

T0

The type of the first event parameter.

T1

The type of the second event parameter.

BindEvent<T0, T1>(UnityEvent<T0, T1>, Func<T0, T1, Task>)

Binds to a UnityEvent with an async action that will be called when the event is triggered.

public void BindEvent<T0, T1>(UnityEvent<T0, T1> evt, Func<T0, T1, Task> action)

Parameters

evt UnityEvent<T0, T1>

The UnityEvent to subscribe to.

action Func<T0, T1, Task>

The async action to invoke when the event is triggered.

Type Parameters

T0

The type of the first event parameter.

T1

The type of the second event parameter.

BindEvent<T0, T1, T2>(UnityEvent<T0, T1, T2>, Action<T0, T1, T2>)

Binds to a UnityEvent with a synchronous action that will be called when the event is triggered.

public void BindEvent<T0, T1, T2>(UnityEvent<T0, T1, T2> evt, Action<T0, T1, T2> action)

Parameters

evt UnityEvent<T0, T1, T2>

The UnityEvent to subscribe to.

action Action<T0, T1, T2>

The action to invoke when the event is triggered.

Type Parameters

T0

The type of the first event parameter.

T1

The type of the second event parameter.

T2

The type of the third event parameter.

BindEvent<T0, T1, T2>(UnityEvent<T0, T1, T2>, Func<T0, T1, T2, Task>)

Binds to a UnityEvent with an async action that will be called when the event is triggered.

public void BindEvent<T0, T1, T2>(UnityEvent<T0, T1, T2> evt, Func<T0, T1, T2, Task> action)

Parameters

evt UnityEvent<T0, T1, T2>

The UnityEvent to subscribe to.

action Func<T0, T1, T2, Task>

The async action to invoke when the event is triggered.

Type Parameters

T0

The type of the first event parameter.

T1

The type of the second event parameter.

T2

The type of the third event parameter.

BindEvent<T0, T1, T2, T3>(UnityEvent<T0, T1, T2, T3>, Action<T0, T1, T2, T3>)

Binds to a UnityEvent with a synchronous action that will be called when the event is triggered.

public void BindEvent<T0, T1, T2, T3>(UnityEvent<T0, T1, T2, T3> evt, Action<T0, T1, T2, T3> action)

Parameters

evt UnityEvent<T0, T1, T2, T3>

The UnityEvent to subscribe to.

action Action<T0, T1, T2, T3>

The action to invoke when the event is triggered.

Type Parameters

T0

The type of the first event parameter.

T1

The type of the second event parameter.

T2

The type of the third event parameter.

T3

The type of the fourth event parameter.

BindEvent<T0, T1, T2, T3>(UnityEvent<T0, T1, T2, T3>, Func<T0, T1, T2, T3, Task>)

Binds to a UnityEvent with an async action that will be called when the event is triggered.

public void BindEvent<T0, T1, T2, T3>(UnityEvent<T0, T1, T2, T3> evt, Func<T0, T1, T2, T3, Task> action)

Parameters

evt UnityEvent<T0, T1, T2, T3>

The UnityEvent to subscribe to.

action Func<T0, T1, T2, T3, Task>

The async action to invoke when the event is triggered.

Type Parameters

T0

The type of the first event parameter.

T1

The type of the second event parameter.

T2

The type of the third event parameter.

T3

The type of the fourth event parameter.

BindFixedUpdate(Action, Func<bool>)

Binds an action to be called every Unity Fixed Update while the context is valid.

public void BindFixedUpdate(Action updateFunc, Func<bool> doneFunc = null)

Parameters

updateFunc Action

The action to call every Fixed Update.

doneFunc Func<bool>

Optional function that returns true when the update should stop.

BindInterval(float, Action, Func<bool>)

Binds an action to be called at regular time intervals while the context is valid.

public void BindInterval(float seconds, Action updateFunc, Func<bool> doneFunc = null)

Parameters

seconds float

The interval in seconds between calls.

updateFunc Action

The action to call at each interval.

doneFunc Func<bool>

Optional function that returns true when the interval calls should stop.

BindListDeferred<T>(IBindableList<T>, Action, Action<int, T>, Action<int, T, T>, Action<int, int>, Action<int, int>, Action<int, T>)

Binds to a bindable list's change events without immediately invoking any callbacks. Allows monitoring of list modifications including additions, changes, moves, swaps, and removals.

public void BindListDeferred<T>(IBindableList<T> list, Action onListChange = null, Action<int, T> onElementAdd = null, Action<int, T, T> onElementChange = null, Action<int, int> onElementMove = null, Action<int, int> onElementSwap = null, Action<int, T> onElementRemove = null)

Parameters

list IBindableList<T>

The bindable list to monitor.

onListChange Action

Called when the list changes in any way.

onElementAdd Action<int, T>

Called when an element is added to the list.

onElementChange Action<int, T, T>

Called when an element in the list is changed.

onElementMove Action<int, int>

Called when an element is moved within the list.

onElementSwap Action<int, int>

Called when two elements are swapped in the list.

onElementRemove Action<int, T>

Called when an element is removed from the list.

Type Parameters

T

The type of elements in the list.

BindListToCreateObjects<TElement, TObject>(IBindable<List<TElement>>, Func<int, TElement, TObject>, Action<int, TElement, TObject>, Action<int, TElement, TObject>)

Binds a list to automatically create, move, and destroy objects based on list changes. Useful for dynamically managing UI elements or game objects that correspond to list items.

public void BindListToCreateObjects<TElement, TObject>(IBindable<List<TElement>> list, Func<int, TElement, TObject> createObject, Action<int, TElement, TObject> moveObject, Action<int, TElement, TObject> destroyObject)

Parameters

list IBindable<List<TElement>>

The bindable list to monitor.

createObject Func<int, TElement, TObject>

Function to create an object for a list element.

moveObject Action<int, TElement, TObject>

Action to reposition an object when its list index changes.

destroyObject Action<int, TElement, TObject>

Action to destroy an object when its element is removed.

Type Parameters

TElement

The type of elements in the list.

TObject

The type of objects to create for each element.

BindListToInstantiate<TElement>(IBindable<List<TElement>>, GameObject, Transform, Action<int, TElement, GameObject>)

Binds a list to automatically instantiate and destroy GameObjects based on list changes. Each list element will have a corresponding GameObject instantiated from the prefab.

public void BindListToInstantiate<TElement>(IBindable<List<TElement>> list, GameObject prefab, Transform parent = null, Action<int, TElement, GameObject> onInstantiate = null)

Parameters

list IBindable<List<TElement>>

The bindable list to monitor.

prefab GameObject

The GameObject prefab to instantiate for each element.

parent Transform

Optional parent transform for instantiated objects.

onInstantiate Action<int, TElement, GameObject>

Optional callback invoked when an object is instantiated.

Type Parameters

TElement

The type of elements in the list.

BindListToInstantiate<TElement, TComponent>(IBindable<List<TElement>>, TComponent, Transform, Action<int, TElement, TComponent>)

Binds a list to automatically instantiate and destroy Components based on list changes. Each list element will have a corresponding Component instantiated from the prefab.

public void BindListToInstantiate<TElement, TComponent>(IBindable<List<TElement>> list, TComponent prefab, Transform parent = null, Action<int, TElement, TComponent> onInstantiate = null) where TComponent : Component

Parameters

list IBindable<List<TElement>>

The bindable list to monitor.

prefab TComponent

The Component prefab to instantiate for each element.

parent Transform

Optional parent transform for instantiated objects.

onInstantiate Action<int, TElement, TComponent>

Optional callback invoked when a component is instantiated.

Type Parameters

TElement

The type of elements in the list.

TComponent

The type of Component to instantiate.

BindList<T>(IBindableList<T>, Action, Action<int, T>, Action<int, T, T>, Action<int, int>, Action<int, int>, Action<int, T>)

Binds to a bindable list's change events and immediately invokes the onListChange callback. Allows monitoring of list modifications including additions, changes, moves, swaps, and removals.

public void BindList<T>(IBindableList<T> list, Action onListChange = null, Action<int, T> onElementAdd = null, Action<int, T, T> onElementChange = null, Action<int, int> onElementMove = null, Action<int, int> onElementSwap = null, Action<int, T> onElementRemove = null)

Parameters

list IBindableList<T>

The bindable list to monitor.

onListChange Action

Called immediately and when the list changes in any way.

onElementAdd Action<int, T>

Called when an element is added to the list.

onElementChange Action<int, T, T>

Called when an element in the list is changed.

onElementMove Action<int, int>

Called when an element is moved within the list.

onElementSwap Action<int, int>

Called when two elements are swapped in the list.

onElementRemove Action<int, T>

Called when an element is removed from the list.

Type Parameters

T

The type of elements in the list.

BindSpriteUri(IBindable<string>, bool, Rect?, Vector2?, float, uint, SpriteMeshType, Vector4, bool, Action<Sprite>)

Binds to a string URI and automatically downloads and creates sprites when the URI changes. Manages sprite and texture lifecycle, releasing previous resources when new ones are loaded.

public void BindSpriteUri(IBindable<string> bindable, bool nonReadable = true, Rect? rect = null, Vector2? pivot = null, float pixelsPerUnit = 100, uint extrude = 0, SpriteMeshType meshType = SpriteMeshType.FullRect, Vector4 border = default, bool generateFallbackPhysicsShape = false, Action<Sprite> onLoad = null)

Parameters

bindable IBindable<string>

The bindable string containing the texture URI.

nonReadable bool

Whether the texture should be non-readable (optimized for GPU).

rect Rect?

Optional rectangle defining the sprite area within the texture.

pivot Vector2?

Optional pivot point for the sprite.

pixelsPerUnit float

How many pixels in the sprite correspond to one unit in world space.

extrude uint

Amount by which the sprite mesh should be expanded outwards.

meshType SpriteMeshType

Controls the type of mesh generated for the sprite.

border Vector4

Vector defining the border sizes for 9-slicing.

generateFallbackPhysicsShape bool

Whether to generate a fallback physics shape for the sprite.

onLoad Action<Sprite>

Optional callback invoked when a sprite is successfully loaded.

BindTextureUri(IBindable<string>, bool, Action<Texture2D>)

Binds to a string URI and automatically downloads textures when the URI changes. Manages texture lifecycle, releasing previous textures when new ones are loaded.

public void BindTextureUri(IBindable<string> bindable, bool nonReadable = true, Action<Texture2D> onLoad = null)

Parameters

bindable IBindable<string>

The bindable string containing the texture URI.

nonReadable bool

Whether the texture should be non-readable (optimized for GPU).

onLoad Action<Texture2D>

Optional callback invoked when a texture is successfully loaded.

BindUpdate(Action, Func<bool>)

Binds an action to be called every Unity Update frame while the context is valid.

public void BindUpdate(Action updateFunc, Func<bool> doneFunc = null)

Parameters

updateFunc Action

The action to call every Update frame.

doneFunc Func<bool>

Optional function that returns true when the update should stop.

Bind<T>(IBindable<T>, Action<T>)

Binds to a bindable value change event and immediately invokes the action with the current value. The action will be called immediately and whenever the bindable value changes.

public void Bind<T>(IBindable<T> bindable, Action<T> action)

Parameters

bindable IBindable<T>

The bindable to subscribe to.

action Action<T>

The action to invoke with the current and future values.

Type Parameters

T

The type of the bindable value.

Get(Object)

Gets or creates a BindContext associated with the specified Unity Object. The context will automatically become invalid when the Unity Object is destroyed.

public static BindContext Get(Object obj)

Parameters

obj Object

The Unity Object to associate with the bind context.

Returns

BindContext

A BindContext instance associated with the specified Unity Object.

Get(VisualElement)

Gets or creates a BindContext associated with the specified VisualElement, which is tracked with a WeakReference. The context will automatically become invalid when the VisualElement is removed from the tree.

public static BindContext Get(VisualElement element)

Parameters

element VisualElement

The VisualElement to associate with the bind context.

Returns

BindContext

A BindContext instance associated with the specified object.

Unbind()

Unbinds all registered listeners and marks this context as invalid. After calling this method, no new bindings can be added to this context.

public void Unbind()