docs.unity3d.com
    Show / Hide Table of Contents

    Class XRInteractableAffordanceStateProvider

    State Machine component that derives an interaction affordance state from an associated IXRInteractable.

    Inheritance
    Object
    Object
    Component
    Behaviour
    MonoBehaviour
    BaseAffordanceStateProvider
    XRInteractableAffordanceStateProvider
    Inherited Members
    BaseAffordanceStateProvider.transitionDuration
    BaseAffordanceStateProvider.isCurrentlyTransitioning
    BaseAffordanceStateProvider.currentAffordanceStateData
    BaseAffordanceStateProvider.OnEnable()
    BaseAffordanceStateProvider.OnDisable()
    BaseAffordanceStateProvider.Update()
    BaseAffordanceStateProvider.AddBinding(IEventBinding)
    BaseAffordanceStateProvider.UpdateAffordanceState(AffordanceStateData)
    BaseAffordanceStateProvider.RegisterAffordanceReceiver(IAffordanceStateReceiver)
    BaseAffordanceStateProvider.UnregisterAffordanceReceiver(IAffordanceStateReceiver)
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(String, Single)
    MonoBehaviour.InvokeRepeating(String, Single, Single)
    MonoBehaviour.CancelInvoke(String)
    MonoBehaviour.IsInvoking(String)
    MonoBehaviour.StartCoroutine(String)
    MonoBehaviour.StartCoroutine(String, Object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(String)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(Object)
    MonoBehaviour.useGUILayout
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, Component)
    Component.TryGetComponent<T>(T)
    Component.GetComponent(String)
    Component.GetComponentInChildren(Type, Boolean)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(Boolean)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, Boolean)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(Boolean)
    Component.GetComponentsInChildren<T>(Boolean, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, Boolean)
    Component.GetComponentInParent(Type)
    UnityEngine.Component.GetComponentInParent<T>(System.Boolean)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, Boolean)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(Boolean)
    Component.GetComponentsInParent<T>(Boolean, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.CompareTag(String)
    Component.SendMessageUpwards(String, Object, SendMessageOptions)
    Component.SendMessageUpwards(String, Object)
    Component.SendMessageUpwards(String)
    Component.SendMessageUpwards(String, SendMessageOptions)
    Component.SendMessage(String, Object)
    Component.SendMessage(String)
    Component.SendMessage(String, Object, SendMessageOptions)
    Component.SendMessage(String, SendMessageOptions)
    Component.BroadcastMessage(String, Object, SendMessageOptions)
    Component.BroadcastMessage(String, Object)
    Component.BroadcastMessage(String)
    Component.BroadcastMessage(String, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(Object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, Boolean)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, Boolean)
    Object.Destroy(Object, Single)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, Boolean)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, Boolean)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.FindObjectsOfType<T>()
    UnityEngine.Object.FindObjectsByType<T>(UnityEngine.FindObjectsSortMode)
    UnityEngine.Object.FindObjectsOfType<T>(System.Boolean)
    UnityEngine.Object.FindObjectsByType<T>(UnityEngine.FindObjectsInactive, UnityEngine.FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    UnityEngine.Object.FindObjectOfType<T>(System.Boolean)
    UnityEngine.Object.FindFirstObjectByType<T>()
    UnityEngine.Object.FindAnyObjectByType<T>()
    UnityEngine.Object.FindFirstObjectByType<T>(UnityEngine.FindObjectsInactive)
    UnityEngine.Object.FindAnyObjectByType<T>(UnityEngine.FindObjectsInactive)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, Boolean)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: UnityEngine.XR.Interaction.Toolkit.AffordanceSystem.State
    Syntax
    [AddComponentMenu("Affordance System/XR Interactable Affordance State Provider", 11)]
    [HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@2.3/api/UnityEngine.XR.Interaction.Toolkit.AffordanceSystem.State.XRInteractableAffordanceStateProvider.html")]
    [DisallowMultipleComponent]
    public class XRInteractableAffordanceStateProvider : BaseAffordanceStateProvider

    Properties

    activateClickAnimationMode

    Condition to trigger click animation for activated interaction events.

    Declaration
    public XRInteractableAffordanceStateProvider.ActivateClickAnimationMode activateClickAnimationMode { get; set; }
    Property Value
    Type Description
    XRInteractableAffordanceStateProvider.ActivateClickAnimationMode

    clickAnimationCurve

    Animation curve reference for click animation events.

    Declaration
    public AnimationCurveDatumProperty clickAnimationCurve { get; set; }
    Property Value
    Type Description
    AnimationCurveDatumProperty

    clickAnimationDuration

    Duration of click animations for selected and activated events.

    Declaration
    public float clickAnimationDuration { get; set; }
    Property Value
    Type Description
    Single

    ignoreActivateEvents

    When activate events are registered and this is true, the state will fallback to idle or disabled.

    Declaration
    public bool ignoreActivateEvents { get; set; }
    Property Value
    Type Description
    Boolean

    ignoreHoverEvents

    When hover events are registered and this is true, the state will fallback to idle or disabled.

    Declaration
    public bool ignoreHoverEvents { get; set; }
    Property Value
    Type Description
    Boolean

    ignoreHoverPriorityEvents

    When hover events are registered and this is true, the state will fallback to hover. When this is false, this provider will check if the Interactable Source has priority for selection when hovered, and update its state accordingly

    Declaration
    public bool ignoreHoverPriorityEvents { get; set; }
    Property Value
    Type Description
    Boolean
    Remarks

    When updating this value to false during runtime, previously hover events are ignored.

    ignoreSelectEvents

    When select events are registered and this is true, the state will fallback to idle or disabled.

    Declaration
    public bool ignoreSelectEvents { get; set; }
    Property Value
    Type Description
    Boolean

    interactableSource

    The interactable component that drives the affordance states. If null, Unity will try and find an interactable component attached.

    Declaration
    public Object interactableSource { get; set; }
    Property Value
    Type Description
    Object

    isActivated

    Is attached interactable in an activated state.

    Declaration
    protected virtual bool isActivated { get; }
    Property Value
    Type Description
    Boolean

    isHovered

    Is attached interactable in a hovered state.

    Declaration
    protected virtual bool isHovered { get; }
    Property Value
    Type Description
    Boolean

    isRegistered

    Is attached interactable in a registered state.

    Declaration
    protected virtual bool isRegistered { get; }
    Property Value
    Type Description
    Boolean

    isSelected

    Is attached interactable in a selected state.

    Declaration
    protected virtual bool isSelected { get; }
    Property Value
    Type Description
    Boolean

    selectClickAnimationMode

    Condition to trigger click animation for Selected interaction events.

    Declaration
    public XRInteractableAffordanceStateProvider.SelectClickAnimationMode selectClickAnimationMode { get; set; }
    Property Value
    Type Description
    XRInteractableAffordanceStateProvider.SelectClickAnimationMode

    Methods

    ActivatedClickBehavior()

    Handles starting the activated click animation coroutine. Stops any previously started coroutine.

    Declaration
    protected virtual void ActivatedClickBehavior()

    Awake()

    See MonoBehaviour.

    Declaration
    protected void Awake()

    BindToProviders()

    Inform all registered receivers of the current affordance state data and subscribe to changes of the affordance state.

    Declaration
    protected override void BindToProviders()
    Overrides
    BaseAffordanceStateProvider.BindToProviders()
    Remarks

    This method is automatically called by Unity when this component is enabled.

    See Also
    OnAffordanceStateUpdated(AffordanceStateData, AffordanceStateData)

    ClearBindings()

    Triggers unbind action on all bindings and destroys all stored binding actions, as well as clears the group of all registered bindings.

    Declaration
    protected override void ClearBindings()
    Overrides
    BaseAffordanceStateProvider.ClearBindings()
    Remarks

    This method is automatically called by Unity when this component is disabled.

    ClickAnimation(Byte, Single, Action)

    Click animation coroutine that plays over a set period of time, transitioning between the lower and upper bounds of a given affordance state.

    Declaration
    protected virtual IEnumerator ClickAnimation(byte targetStateIndex, float duration, Action onComplete = null)
    Parameters
    Type Name Description
    Byte targetStateIndex

    Target animation state with bounds which to transition between.

    Single duration

    Duration of the animation.

    Action onComplete

    OnComplete callback action.

    Returns
    Type Description
    IEnumerator

    Enumerator used to play as a coroutine.

    GenerateNewAffordanceState()

    Evaluates the state of the current interactable to generate a corresponding AffordanceStateData.

    Declaration
    protected virtual AffordanceStateData GenerateNewAffordanceState()
    Returns
    Type Description
    AffordanceStateData

    Newly generated affordance state corresponding to the interactable state.

    OnActivatedEvent(ActivateEventArgs)

    Callback triggered by IXRActivateInteractable when the interactor triggers an activated event on the interactable. Refreshes the affordance state and triggers the ActivatedClickBehavior() animation coroutine if the activated animation mode is set to Activated.

    Declaration
    protected virtual void OnActivatedEvent(ActivateEventArgs args)
    Parameters
    Type Name Description
    ActivateEventArgs args

    ActivateEventArgs callback args.

    See Also
    activated

    OnDeactivatedEvent(DeactivateEventArgs)

    Callback triggered by IXRActivateInteractable when the interactor triggers an deactivated event on the interactable. Refreshes the affordance state and triggers the ActivatedClickBehavior() animation coroutine if the activated animation mode is set to deactivated.

    Declaration
    protected virtual void OnDeactivatedEvent(DeactivateEventArgs args)
    Parameters
    Type Name Description
    DeactivateEventArgs args

    DeactivateEventArgs callback args.

    See Also
    deactivated

    OnFirstHoverEntered(HoverEnterEventArgs)

    Callback triggered by IXRHoverInteractable when the first interactor begins hovering over this interactable. Refreshes the affordance state.

    Declaration
    protected virtual void OnFirstHoverEntered(HoverEnterEventArgs args)
    Parameters
    Type Name Description
    HoverEnterEventArgs args

    HoverEnterEventArgs callback args.

    See Also
    firstHoverEntered

    OnFirstSelectEntered(SelectEnterEventArgs)

    Callback triggered by IXRSelectInteractor when the first interactor begins selecting over this interactable. Refreshes the affordance state and triggers the SelectedClickBehavior() animation coroutine if the select animation mode is set to SelectEntered.

    Declaration
    protected virtual void OnFirstSelectEntered(SelectEnterEventArgs args)
    Parameters
    Type Name Description
    SelectEnterEventArgs args

    SelectEnterEventArgs callback args.

    See Also
    firstSelectEntered

    OnHoverEntered(HoverEnterEventArgs)

    Callback triggered by IXRHoverInteractable when an interactor begins hovering over this interactable. Refreshes the affordance state.

    Declaration
    protected virtual void OnHoverEntered(HoverEnterEventArgs args)
    Parameters
    Type Name Description
    HoverEnterEventArgs args

    HoverEnterEventArgs callback args.

    See Also
    hoverEntered

    OnHoverExited(HoverExitEventArgs)

    Callback triggered by IXRHoverInteractable when an interactor exits hovering over this interactable. Refreshes the affordance state.

    Declaration
    protected virtual void OnHoverExited(HoverExitEventArgs args)
    Parameters
    Type Name Description
    HoverExitEventArgs args

    HoverExitEventArgs callback args.

    See Also
    hoverExited

    OnLargestInteractionStrengthChanged(Single)

    Callback triggered by IXRInteractionStrengthInteractable when the largest interaction strength of the interactable changes. Refreshes the affordance state.

    Declaration
    protected virtual void OnLargestInteractionStrengthChanged(float value)
    Parameters
    Type Name Description
    Single value

    The new largest interaction strength value of all interactors hovering or selecting the interactable.

    OnLastHoverExited(HoverExitEventArgs)

    Callback triggered by IXRHoverInteractable when the last interactor exits hovering over this interactable. Refreshes the affordance state.

    Declaration
    protected virtual void OnLastHoverExited(HoverExitEventArgs args)
    Parameters
    Type Name Description
    HoverExitEventArgs args

    HoverExitEventArgs callback args.

    See Also
    lastHoverExited

    OnLastSelectExited(SelectExitEventArgs)

    Callback triggered by IXRSelectInteractor when the last interactor exits selecting over this interactable. Refreshes the affordance state and triggers the SelectedClickBehavior() animation coroutine if the select animation mode is set to SelectExited.

    Declaration
    protected virtual void OnLastSelectExited(SelectExitEventArgs args)
    Parameters
    Type Name Description
    SelectExitEventArgs args

    SelectExitEventArgs callback args.

    See Also
    lastSelectExited

    OnRegistered(InteractableRegisteredEventArgs)

    Callback triggered when the interactable is registered with the XRInteractionManager. Sets the internal isRegistered flag to true and refreshes the affordance state.

    Declaration
    protected virtual void OnRegistered(InteractableRegisteredEventArgs args)
    Parameters
    Type Name Description
    InteractableRegisteredEventArgs args

    InteractableRegisteredEventArgs callback args.

    OnUnregistered(InteractableUnregisteredEventArgs)

    Callback triggered when the interactable is unregistered with the XRInteractionManager. Sets the internal isRegistered flag to false and refreshes the affordance state.

    Declaration
    protected virtual void OnUnregistered(InteractableUnregisteredEventArgs args)
    Parameters
    Type Name Description
    InteractableUnregisteredEventArgs args

    InteractableUnregisteredEventArgs callback args.

    OnValidate()

    See MonoBehaviour.

    Declaration
    protected override void OnValidate()
    Overrides
    BaseAffordanceStateProvider.OnValidate()

    RefreshState()

    Re-evaluates the current affordance state and triggers events for receivers if it changed.

    Declaration
    public void RefreshState()

    SelectedClickBehavior()

    Handles starting the selected click animation coroutine. Stops any previously started coroutine.

    Declaration
    protected virtual void SelectedClickBehavior()

    SetBoundInteractionReceiver(IXRInteractable)

    Bind affordance provider state to IXRInteractable state and events.

    Declaration
    public bool SetBoundInteractionReceiver(IXRInteractable receiver)
    Parameters
    Type Name Description
    IXRInteractable receiver

    Receiver to bind events from.

    Returns
    Type Description
    Boolean

    Whether binding was successful.

    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