docs.unity.cn
Search Results for

    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
    Assembly: solution.dll
    Syntax
    public interface IReadOnlyBindableVariable<T>
    Type Parameters
    Name Description
    T

    The type of the variable value.

    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

    Get internal variable value.

    Methods

    Name Description
    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.

    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)