docs.unity.cn
Search Results for

    Show / Hide Table of Contents

    Class BindableVariableBase<T>

    Abstract class which contains a member variable of type T and provides a binding API to data changes.

    Inheritance
    object
    BindableVariableBase<T>
    BindableEnum<T>
    BindableVariableAlloc<T>
    BindableVariable<T>
    Implements
    IReadOnlyBindableVariable<T>
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Unity.XR.CoreUtils.Bindings.Variables
    Assembly: solution.dll
    Syntax
    [Serializable]
    public abstract class BindableVariableBase<T> : IReadOnlyBindableVariable<T>
    Type Parameters
    Name Description
    T

    The type of the variable value.

    Constructors

    Name Description
    BindableVariableBase(T, bool, Func<T, T, bool>, bool)

    Constructor for bindable variable, which is a variable that notifies listeners when the internal value changes.

    Properties

    Name Description
    BindingCount

    Get number of subscribed binding callbacks. Note that if you manually call Unsubscribe(Action<T>) with the same callback several times this value may be inaccurate. For best results leverage the IEventBinding returned by the subscribe call and use that to unsubscribe as needed.

    Value

    The internal variable value. When setting the value, subscribers may be notified. The subscribers will not be notified if this variable is initialized, is configured to check for equality, and the new value is equivalent.

    Methods

    Name Description
    BroadcastValue()

    Triggers a callback for all subscribed listeners with the current internal variable value.

    SetValueWithoutNotify(T)

    Sets the internal variable value and, even if different, doesn't notify of the change to subscribed listeners. This is intended to be used by developers to allow for setting multiple bindable variables before broadcasting any of them individually.

    Subscribe(Action<T>)

    Register callback to the event that is invoked when the value is updated.

    SubscribeAndUpdate(Action<T>)

    Triggers the callback inline, followed by the Subscribe(Action<T>) function.

    Task(Func<T, bool>, CancellationToken)

    Wait until predicate is met, or until token is called. A null predicate can be passed to have it await any change.

    Task(T, CancellationToken)

    Wait until BindableVariable is set to awaitState.

    Unsubscribe(Action<T>)

    Manually unsubscribe callback from Value update event, but no protections from multiple unsubscribe calls. If unsubscribing multiple times, reference count may not be accurate.

    ValueEquals(T)

    Evaluates equality with the internal value held by the bindable variable.

    See Also

    BindableVariable<T>
    BindableVariableAlloc<T>
    BindableEnum<T>
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)