docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class BindableEnum<T>

    Class which contains an enum member variable of type T and provides a binding API to data changes.

    Inheritance
    object
    BindableVariableBase<T>
    BindableEnum<T>
    Implements
    IReadOnlyBindableVariable<T>
    Inherited Members
    BindableVariableBase<T>.Value
    BindableVariableBase<T>.BindingCount
    BindableVariableBase<T>.SetValueWithoutNotify(T)
    BindableVariableBase<T>.Subscribe(Action<T>)
    BindableVariableBase<T>.SubscribeAndUpdate(Action<T>)
    BindableVariableBase<T>.Unsubscribe(Action<T>)
    BindableVariableBase<T>.BroadcastValue()
    BindableVariableBase<T>.Task(Func<T, bool>, CancellationToken)
    BindableVariableBase<T>.Task(T, CancellationToken)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.XR.CoreUtils.Bindings.Variables
    Assembly: Unity.XR.CoreUtils.dll
    Syntax
    public class BindableEnum<T> : BindableVariableBase<T>, IReadOnlyBindableVariable<T> where T : struct, IConvertible
    Type Parameters
    Name Description
    T

    The type of the variable enum.

    Remarks

    Uses GetHashCode for comparison since Equals on an enum causes GC alloc.

    Constructors

    BindableEnum(T, bool, Func<T, T, bool>, bool)

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

    Declaration
    public BindableEnum(T initialValue = default, bool checkEquality = true, Func<T, T, bool> equalityMethod = null, bool startInitialized = false)
    Parameters
    Type Name Description
    T initialValue

    Enum value of type T to initialize enum with. Defaults to type default.

    bool checkEquality

    Setting true checks whether to compare new enum to old before triggering callback. Defaults to true.

    Func<T, T, bool> equalityMethod

    Func used to provide custom equality checking behavior. Defaults to Equals check.

    bool startInitialized

    Setting false results in initial enum setting will trigger registered callbacks, regardless of whether the value is the same as the initial one. Defaults to false.

    Methods

    ValueEquals(T)

    Performs equal operation by comparing hash codes.

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

    Other enum to compare with.

    Returns
    Type Description
    bool

    Returns true if equal, returns false otherwise.

    Overrides
    BindableVariableBase<T>.ValueEquals(T)

    Implements

    IReadOnlyBindableVariable<T>
    In This Article
    Back to top
    Copyright © 2025 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)