docs.unity3d.com
    Show / Hide Table of Contents

    Interface IReadOnlyBindableVariable<T>

    Bindable variable interface useful for removing write capability from external access, while preserving the ability to subscribe to changes.

    Namespace: Unity.XR.CoreUtils.Bindings.Variables
    Syntax
    public interface IReadOnlyBindableVariable<T>
    Type Parameters
    Name Description
    T

    The type of the variable value.

    Properties

    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.

    Declaration
    int BindingCount { get; }
    Property Value
    Type Description
    Int32

    Value

    Get internal variable value.

    Declaration
    T Value { get; }
    Property Value
    Type Description
    T

    Methods

    Subscribe(Action<T>)

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

    Declaration
    IEventBinding Subscribe(Action<T> callback)
    Parameters
    Type Name Description
    Action<T> callback

    Callback to register.

    Returns
    Type Description
    IEventBinding

    IEventBinding which allows for safe and easy bind, unbind, and clear functions.

    SubscribeAndUpdate(Action<T>)

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

    Declaration
    IEventBinding SubscribeAndUpdate(Action<T> callback)
    Parameters
    Type Name Description
    Action<T> callback

    Callback to register.

    Returns
    Type Description
    IEventBinding

    IEventBinding which allows for safe and easy bind, unbind, and clear functions.

    Task(T, CancellationToken)

    Wait until BindableVariable is set to awaitState.

    Declaration
    Task<T> Task(T awaitState, CancellationToken token = default(CancellationToken))
    Parameters
    Type Name Description
    T awaitState

    Variable state to wait for.

    CancellationToken token

    Token used to trigger a cancellation of the task.

    Returns
    Type Description
    Task<T>

    Task to schedule.

    Task(Func<T, Boolean>, CancellationToken)

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

    Declaration
    Task<T> Task(Func<T, bool> awaitPredicate, CancellationToken token = default(CancellationToken))
    Parameters
    Type Name Description
    Func<T, Boolean> awaitPredicate

    Callback to be executed on completion of task.

    CancellationToken token

    Token used to trigger a cancellation of the task.

    Returns
    Type Description
    Task<T>

    Task to schedule.

    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.

    Declaration
    void Unsubscribe(Action<T> callback)
    Parameters
    Type Name Description
    Action<T> callback

    ValueEquals(T)

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

    Declaration
    bool ValueEquals(T other)
    Parameters
    Type Name Description
    T other

    Other value to compare equality against.

    Returns
    Type Description
    Boolean

    True if both values are equal.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023