Class XRBaseInteractable | XR Interaction Toolkit | 0.10.0-preview.7
docs.unity3d.com
    Show / Hide Table of Contents

    Class XRBaseInteractable

    Abstract base class from which all interactable behaviours derive. This class hooks into the interaction system (via XRInteractionManager) and provides base virtual methods for handling hover and selection.

    Inheritance
    Object
    Object
    Component
    Behaviour
    MonoBehaviour
    XRBaseInteractable
    BaseTeleportationInteractable
    XRGrabInteractable
    XRSimpleInteractable
    Inherited Members
    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.StartCoroutine_Auto(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)
    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
    Component.rigidbody
    Component.rigidbody2D
    Component.camera
    Component.light
    Component.animation
    Component.constantForce
    Component.renderer
    Component.audio
    Component.networkView
    Component.collider
    Component.collider2D
    Component.hingeJoint
    Component.particleSystem
    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.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, Single)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectOfType<T>()
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.ToString()
    Object.name
    Object.hideFlags
    Namespace: UnityEngine.XR.Interaction.Toolkit
    Syntax
    [SelectionBase]
    [DefaultExecutionOrder(-98)]
    public abstract class XRBaseInteractable : MonoBehaviour

    Properties

    colliders

    (Read Only) Colliders to use for interaction with this interactable (if empty, will use any child colliders).

    Declaration
    public List<Collider> colliders { get; }
    Property Value
    Type Description
    List<Collider>

    customReticle

    The reticle that will appear at the end of the line when it is valid.

    Declaration
    public GameObject customReticle { get; set; }
    Property Value
    Type Description
    GameObject

    hoveringInteractors

    (Read Only) The list of interactors that are hovering on this interactable.

    Declaration
    public List<XRBaseInteractor> hoveringInteractors { get; }
    Property Value
    Type Description
    List<XRBaseInteractor>

    interactionLayerMask

    Only interactors with this Layer Mask will interact with this interactable.

    Declaration
    public LayerMask interactionLayerMask { get; set; }
    Property Value
    Type Description
    LayerMask

    interactionManager

    Manager to handle all interaction management (will find one if empty).

    Declaration
    public XRInteractionManager interactionManager { get; set; }
    Property Value
    Type Description
    XRInteractionManager

    isHovered

    (Read Only) Indicates whether this interactable is currently being hovered.

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

    isSelected

    (Read Only) Indicates whether this interactable is currently being selected.

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

    onActivate

    Called when an Interactor activates this selected Interactable.

    Declaration
    public XRInteractableEvent onActivate { get; set; }
    Property Value
    Type Description
    XRInteractableEvent

    onDeactivate

    Called when an Interactor deactivates this selected Interactable.

    Declaration
    public XRInteractableEvent onDeactivate { get; set; }
    Property Value
    Type Description
    XRInteractableEvent

    onFirstHoverEnter

    Declaration
    [Obsolete("onFirstHoverEnter has been deprecated. Use onFirstHoverEntered instead. (UnityUpgradable) -> onFirstHoverEntered")]
    public XRInteractableEvent onFirstHoverEnter { get; }
    Property Value
    Type Description
    XRInteractableEvent

    onFirstHoverEntered

    Called only when the first interactor begins hovering over this interactable.

    Declaration
    public XRInteractableEvent onFirstHoverEntered { get; set; }
    Property Value
    Type Description
    XRInteractableEvent

    onHoverEnter

    Declaration
    [Obsolete("onHoverEnter has been deprecated. Use onHoverEntered instead. (UnityUpgradable) -> onHoverEntered")]
    public XRInteractableEvent onHoverEnter { get; }
    Property Value
    Type Description
    XRInteractableEvent

    onHoverEntered

    Called every time when an interactor begins hovering over this interactable.

    Declaration
    public XRInteractableEvent onHoverEntered { get; set; }
    Property Value
    Type Description
    XRInteractableEvent

    onHoverExit

    Declaration
    [Obsolete("onHoverExit has been deprecated. Use onHoverExited instead. (UnityUpgradable) -> onHoverExited")]
    public XRInteractableEvent onHoverExit { get; }
    Property Value
    Type Description
    XRInteractableEvent

    onHoverExited

    Called every time when an interactor stops hovering over this interactable.

    Declaration
    public XRInteractableEvent onHoverExited { get; set; }
    Property Value
    Type Description
    XRInteractableEvent

    onLastHoverExit

    Declaration
    [Obsolete("onLastHoverExit has been deprecated. Use onLastHoverExited instead. (UnityUpgradable) -> onLastHoverExited")]
    public XRInteractableEvent onLastHoverExit { get; }
    Property Value
    Type Description
    XRInteractableEvent

    onLastHoverExited

    Called only when the last interactor stops hovering over this interactable.

    Declaration
    public XRInteractableEvent onLastHoverExited { get; set; }
    Property Value
    Type Description
    XRInteractableEvent

    onSelectCancel

    Declaration
    [Obsolete("onSelectCancel has been deprecated. Use onSelectCanceled instead. (UnityUpgradable) -> onSelectCanceled")]
    public XRInteractableEvent onSelectCancel { get; }
    Property Value
    Type Description
    XRInteractableEvent

    onSelectCanceled

    Called when the interactor selecting this interactable is disabled or destroyed.

    Declaration
    public XRInteractableEvent onSelectCanceled { get; set; }
    Property Value
    Type Description
    XRInteractableEvent

    onSelectEnter

    Declaration
    [Obsolete("onSelectEnter has been deprecated. Use onSelectEntered instead. (UnityUpgradable) -> onSelectEntered")]
    public XRInteractableEvent onSelectEnter { get; }
    Property Value
    Type Description
    XRInteractableEvent

    onSelectEntered

    Called when an interactor begins selecting this interactable.

    Declaration
    public XRInteractableEvent onSelectEntered { get; set; }
    Property Value
    Type Description
    XRInteractableEvent

    onSelectExit

    Declaration
    [Obsolete("onSelectExit has been deprecated. Use onSelectExited instead. (UnityUpgradable) -> onSelectExited")]
    public XRInteractableEvent onSelectExit { get; }
    Property Value
    Type Description
    XRInteractableEvent

    onSelectExited

    Called when an interactor stops selecting this interactable.

    Declaration
    public XRInteractableEvent onSelectExited { get; set; }
    Property Value
    Type Description
    XRInteractableEvent

    Methods

    AttachCustomReticle(XRBaseInteractor)

    Declaration
    public virtual void AttachCustomReticle(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    Awake()

    Declaration
    protected virtual void Awake()

    GetDistanceSqrToInteractor(XRBaseInteractor)

    Calculates distance squared to interactor (based on colliders).

    Declaration
    public float GetDistanceSqrToInteractor(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    Interactor to calculate distance against.

    Returns
    Type Description
    Single

    Returns the minimum distance between the interactor and this interactable's colliders.

    IsHoverableBy(XRBaseInteractor)

    Determines if this interactable can be hovered by a given interactor.

    Declaration
    public virtual bool IsHoverableBy(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    Interactor to check for a valid hover state with.

    Returns
    Type Description
    Boolean

    Returns true if hovering is valid this frame. Returns false if not.

    IsSelectableBy(XRBaseInteractor)

    Determines if this interactable can be selected by a given interactor.

    Declaration
    public virtual bool IsSelectableBy(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    Interactor to check for a valid selection with.

    Returns
    Type Description
    Boolean

    Returns true if selection is valid this frame. Returns false if not.

    OnActivate(XRBaseInteractor)

    This method is called by the interaction manager when the interactor sends an activation event down to an interactable.

    Declaration
    protected virtual void OnActivate(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    Interactor that is sending the activation event.

    OnDeactivate(XRBaseInteractor)

    Declaration
    protected virtual void OnDeactivate(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    OnDestroy()

    Declaration
    protected virtual void OnDestroy()

    OnHoverEntered(XRBaseInteractor)

    This method is called by the interaction manager when the interactor first initiates hovering over an interactable.

    Declaration
    protected virtual void OnHoverEntered(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    Interactor that is initiating the hover.

    See Also
    OnHoverExited(XRBaseInteractor)

    OnHoverEntering(XRBaseInteractor)

    This method is called by the interaction manager right before the interactor first initiates hovering over an interactable.

    Declaration
    protected virtual void OnHoverEntering(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    Interactor that is initiating the hover.

    See Also
    OnHoverEntered(XRBaseInteractor)

    OnHoverExited(XRBaseInteractor)

    This method is called by the interaction manager when the interactor ends hovering over an interactable.

    Declaration
    protected virtual void OnHoverExited(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    Interactor that is ending the hover.

    See Also
    OnHoverEntered(XRBaseInteractor)

    OnHoverExiting(XRBaseInteractor)

    This method is called by the interaction manager right before the interactor ends hovering over an interactable.

    Declaration
    protected virtual void OnHoverExiting(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    Interactor that is ending the hover.

    See Also
    OnHoverExited(XRBaseInteractor)

    OnSelectCanceled(XRBaseInteractor)

    This method is called by the interaction manager when the interactor targeting this interactable is disabled or destroyed, or if the interactable is unregistered.

    Declaration
    protected virtual void OnSelectCanceled(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    Interactor that is ending the selection.

    See Also
    OnSelectEntered(XRBaseInteractor)
    OnSelectExited(XRBaseInteractor)

    OnSelectCanceling(XRBaseInteractor)

    This method is called by the interaction manager right before the interactor targeting this interactable is disabled or destroyed, or if the interactable is unregistered.

    Declaration
    protected virtual void OnSelectCanceling(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    Interactor that is ending the selection.

    See Also
    OnSelectEntered(XRBaseInteractor)
    OnSelectExited(XRBaseInteractor)

    OnSelectEntered(XRBaseInteractor)

    This method is called by the interaction manager when the interactor first initiates selection of an interactable.

    Declaration
    protected virtual void OnSelectEntered(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    Interactor that is initiating the selection.

    See Also
    OnSelectExited(XRBaseInteractor)
    OnSelectCanceled(XRBaseInteractor)

    OnSelectEntering(XRBaseInteractor)

    This method is called by the interaction manager right before the interactor first initiates selection of an interactable.

    Declaration
    protected virtual void OnSelectEntering(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    Interactor that is initiating the selection.

    See Also
    OnSelectEntered(XRBaseInteractor)

    OnSelectExited(XRBaseInteractor)

    This method is called by the interaction manager when the interactor ends selection of an interactable.

    Declaration
    protected virtual void OnSelectExited(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    Interactor that is ending the selection.

    See Also
    OnSelectEntered(XRBaseInteractor)
    OnSelectCanceled(XRBaseInteractor)

    OnSelectExiting(XRBaseInteractor)

    This method is called by the interaction manager right before the interactor ends selection of an interactable.

    Declaration
    protected virtual void OnSelectExiting(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    Interactor that is ending the selection.

    See Also
    OnSelectExited(XRBaseInteractor)

    ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase)

    This method is called by the interaction manager to update the interactable. Please see the interaction manager documentation for more details on update order.

    Declaration
    public virtual void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    Parameters
    Type Name Description
    XRInteractionUpdateOrder.UpdatePhase updatePhase

    RemoveCustomReticle(XRBaseInteractor)

    Declaration
    public virtual void RemoveCustomReticle(XRBaseInteractor interactor)
    Parameters
    Type Name Description
    XRBaseInteractor interactor

    Reset()

    Declaration
    [Conditional("UNITY_EDITOR")]
    protected virtual void Reset()
    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