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
isValidFunc<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
cancellationTokenCancellationTokenThe 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
objObjectThe 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
elementVisualElement
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
Methods
AddUnbindAction(Action)
Adds an action to be executed when this context is unbound.
public void AddUnbindAction(Action unbind)
Parameters
unbindActionThe 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
bindable1IBindableThe first bindable to subscribe to.
bindable2IBindableThe second bindable to subscribe to.
bindable3IBindableThe third bindable to subscribe to.
bindable4IBindableThe fourth bindable to subscribe to.
actionActionThe 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
bindable1IBindableThe first bindable to subscribe to.
bindable2IBindableThe second bindable to subscribe to.
bindable3IBindableThe third bindable to subscribe to.
actionActionThe 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
bindable1IBindableThe first bindable to subscribe to.
bindable2IBindableThe second bindable to subscribe to.
actionActionThe 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
bindableIBindableThe bindable to subscribe to.
actionActionThe 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
bindableIBindable<string>The bindable string containing the audio clip URI.
audioTypeAudioTypeThe type of audio format to expect. AudioType.UNKNOWN will auto-detect.
onLoadAction<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
bindable1IBindableThe first bindable to subscribe to.
bindable2IBindableThe second bindable to subscribe to.
bindable3IBindableThe third bindable to subscribe to.
bindable4IBindableThe fourth bindable to subscribe to.
actionActionThe 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
bindable1IBindableThe first bindable to subscribe to.
bindable2IBindableThe second bindable to subscribe to.
bindable3IBindableThe third bindable to subscribe to.
actionActionThe 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
bindable1IBindableThe first bindable to subscribe to.
bindable2IBindableThe second bindable to subscribe to.
actionActionThe 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
bindableIBindableThe bindable to subscribe to.
actionActionThe 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
bindableIBindable<T>The bindable to subscribe to.
actionAction<T>The action to invoke when the value changes.
Type Parameters
TThe 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
dictIBindableDictionary<TKey, TValue>The bindable dictionary to monitor.
onChangeActionCalled when the dictionary changes in any way.
onElementAddAction<TKey, TValue>Called when an element is added to the dictionary.
onElementChangeAction<TKey, TValue, TValue>Called when an element value in the dictionary is changed.
onElementRemoveAction<TKey, TValue>Called when an element is removed from the dictionary.
Type Parameters
TKeyThe type of keys in the dictionary.
TValueThe 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
dictIBindable<Dictionary<TKey, TValue>>The bindable dictionary to monitor.
createObjectFunc<TKey, TValue, TObject>Function to create an object for a dictionary entry.
destroyObjectAction<TKey, TValue, TObject>Action to destroy an object when its entry is removed.
Type Parameters
TKeyThe type of keys in the dictionary.
TValueThe type of values in the dictionary.
TObjectThe 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
dictIBindable<Dictionary<TKey, TValue>>The bindable dictionary to monitor.
prefabGameObjectThe GameObject prefab to instantiate for each entry.
parentTransformOptional parent transform for instantiated objects.
onInstantiateAction<TKey, TValue, GameObject>Optional callback invoked when an object is instantiated.
Type Parameters
TKeyThe type of keys in the dictionary.
TValueThe 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
dictIBindable<Dictionary<TKey, TValue>>The bindable dictionary to monitor.
prefabTComponentThe Component prefab to instantiate for each entry.
parentTransformOptional parent transform for instantiated objects.
onInstantiateAction<TKey, TValue, TComponent>Optional callback invoked when a component is instantiated.
Type Parameters
TKeyThe type of keys in the dictionary.
TValueThe type of values in the dictionary.
TComponentThe 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
dictIBindableDictionary<TKey, TValue>The bindable dictionary to monitor.
onChangeActionCalled immediately and when the dictionary changes in any way.
onElementAddAction<TKey, TValue>Called when an element is added to the dictionary.
onElementChangeAction<TKey, TValue, TValue>Called when an element value in the dictionary is changed.
onElementRemoveAction<TKey, TValue>Called when an element is removed from the dictionary.
Type Parameters
TKeyThe type of keys in the dictionary.
TValueThe 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
updateFuncActionThe action to call at the end of every frame.
doneFuncFunc<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
evtUnityEventThe UnityEvent to subscribe to.
actionActionThe 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
evtUnityEventThe UnityEvent to subscribe to.
actionFunc<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
evtUnityEvent<T>The UnityEvent to subscribe to.
actionAction<T>The action to invoke when the event is triggered.
Type Parameters
TThe 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
evtUnityEvent<T>The UnityEvent to subscribe to.
actionFunc<T, Task>The async action to invoke when the event is triggered.
Type Parameters
TThe 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
elementCallbackEventHandlercallbackActionuseTrickleDownTrickleDown
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
elementCallbackEventHandlercallbackEventCallback<TEvent>useTrickleDownTrickleDown
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
evtUnityEvent<T0, T1>The UnityEvent to subscribe to.
actionAction<T0, T1>The action to invoke when the event is triggered.
Type Parameters
T0The type of the first event parameter.
T1The 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
evtUnityEvent<T0, T1>The UnityEvent to subscribe to.
actionFunc<T0, T1, Task>The async action to invoke when the event is triggered.
Type Parameters
T0The type of the first event parameter.
T1The 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
evtUnityEvent<T0, T1, T2>The UnityEvent to subscribe to.
actionAction<T0, T1, T2>The action to invoke when the event is triggered.
Type Parameters
T0The type of the first event parameter.
T1The type of the second event parameter.
T2The 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
evtUnityEvent<T0, T1, T2>The UnityEvent to subscribe to.
actionFunc<T0, T1, T2, Task>The async action to invoke when the event is triggered.
Type Parameters
T0The type of the first event parameter.
T1The type of the second event parameter.
T2The 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
evtUnityEvent<T0, T1, T2, T3>The UnityEvent to subscribe to.
actionAction<T0, T1, T2, T3>The action to invoke when the event is triggered.
Type Parameters
T0The type of the first event parameter.
T1The type of the second event parameter.
T2The type of the third event parameter.
T3The 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
evtUnityEvent<T0, T1, T2, T3>The UnityEvent to subscribe to.
actionFunc<T0, T1, T2, T3, Task>The async action to invoke when the event is triggered.
Type Parameters
T0The type of the first event parameter.
T1The type of the second event parameter.
T2The type of the third event parameter.
T3The 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
updateFuncActionThe action to call every Fixed Update.
doneFuncFunc<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
secondsfloatThe interval in seconds between calls.
updateFuncActionThe action to call at each interval.
doneFuncFunc<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
listIBindableList<T>The bindable list to monitor.
onListChangeActionCalled when the list changes in any way.
onElementAddAction<int, T>Called when an element is added to the list.
onElementChangeAction<int, T, T>Called when an element in the list is changed.
onElementMoveAction<int, int>Called when an element is moved within the list.
onElementSwapAction<int, int>Called when two elements are swapped in the list.
onElementRemoveAction<int, T>Called when an element is removed from the list.
Type Parameters
TThe 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
listIBindable<List<TElement>>The bindable list to monitor.
createObjectFunc<int, TElement, TObject>Function to create an object for a list element.
moveObjectAction<int, TElement, TObject>Action to reposition an object when its list index changes.
destroyObjectAction<int, TElement, TObject>Action to destroy an object when its element is removed.
Type Parameters
TElementThe type of elements in the list.
TObjectThe 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
listIBindable<List<TElement>>The bindable list to monitor.
prefabGameObjectThe GameObject prefab to instantiate for each element.
parentTransformOptional parent transform for instantiated objects.
onInstantiateAction<int, TElement, GameObject>Optional callback invoked when an object is instantiated.
Type Parameters
TElementThe 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
listIBindable<List<TElement>>The bindable list to monitor.
prefabTComponentThe Component prefab to instantiate for each element.
parentTransformOptional parent transform for instantiated objects.
onInstantiateAction<int, TElement, TComponent>Optional callback invoked when a component is instantiated.
Type Parameters
TElementThe type of elements in the list.
TComponentThe 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
listIBindableList<T>The bindable list to monitor.
onListChangeActionCalled immediately and when the list changes in any way.
onElementAddAction<int, T>Called when an element is added to the list.
onElementChangeAction<int, T, T>Called when an element in the list is changed.
onElementMoveAction<int, int>Called when an element is moved within the list.
onElementSwapAction<int, int>Called when two elements are swapped in the list.
onElementRemoveAction<int, T>Called when an element is removed from the list.
Type Parameters
TThe 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
bindableIBindable<string>The bindable string containing the texture URI.
nonReadableboolWhether the texture should be non-readable (optimized for GPU).
rectRect?Optional rectangle defining the sprite area within the texture.
pivotVector2?Optional pivot point for the sprite.
pixelsPerUnitfloatHow many pixels in the sprite correspond to one unit in world space.
extrudeuintAmount by which the sprite mesh should be expanded outwards.
meshTypeSpriteMeshTypeControls the type of mesh generated for the sprite.
borderVector4Vector defining the border sizes for 9-slicing.
generateFallbackPhysicsShapeboolWhether to generate a fallback physics shape for the sprite.
onLoadAction<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
bindableIBindable<string>The bindable string containing the texture URI.
nonReadableboolWhether the texture should be non-readable (optimized for GPU).
onLoadAction<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
updateFuncActionThe action to call every Update frame.
doneFuncFunc<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
bindableIBindable<T>The bindable to subscribe to.
actionAction<T>The action to invoke with the current and future values.
Type Parameters
TThe 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
objObjectThe 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
elementVisualElementThe 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()