docs.unity3d.com
    Show / Hide Table of Contents

    Interface IXRInteractable

    An interface that represents an Interactable component that controls how a GameObject interacts with an Interactor component. An example is a Grab Interactable which can be picked up and moved by an Interactor.

    Namespace: UnityEngine.XR.Interaction.Toolkit
    Syntax
    public interface IXRInteractable
    Remarks

    When scripting, you can typically write custom behaviors that derive from XRBaseInteractable or one of its derived classes rather than implementing this interface directly.

    Properties

    colliders

    (Read Only) Colliders to use for interaction with this Interactable.

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

    interactionLayers

    (Read Only) Allows interaction with Interactors whose Interaction Layer Mask overlaps with any Layer in this Interaction Layer Mask.

    Declaration
    InteractionLayerMask interactionLayers { get; }
    Property Value
    Type Description
    InteractionLayerMask
    See Also
    interactionLayers

    transform

    (Read Only) The Transform associated with the Interactable.

    Declaration
    Transform transform { get; }
    Property Value
    Type Description
    Transform
    Remarks

    When this Interactable is a component, this property is the Transform of the GameObject the component is attached to.

    Methods

    GetAttachTransform(IXRInteractor)

    Gets the Transform that serves as the attachment point for a given Interactor.

    Declaration
    Transform GetAttachTransform(IXRInteractor interactor)
    Parameters
    Type Name Description
    IXRInteractor interactor

    The specific Interactor as context to get the attachment point for.

    Returns
    Type Description
    Transform

    Returns the attachment point Transform.

    Remarks

    This should typically return the Transform of a child GameObject or the transform itself.

    See Also
    GetAttachTransform(IXRInteractable)

    GetDistanceSqrToInteractor(IXRInteractor)

    Calculates squared distance to an Interactor (based on colliders).

    Declaration
    float GetDistanceSqrToInteractor(IXRInteractor interactor)
    Parameters
    Type Name Description
    IXRInteractor interactor

    Interactor to calculate distance against.

    Returns
    Type Description
    Single

    Returns the minimum squared distance between the Interactor and this Interactable's colliders.

    OnRegistered(InteractableRegisteredEventArgs)

    The XRInteractionManager calls this method when this Interactable is registered with it.

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

    Event data containing the Interaction Manager that registered this Interactable.

    Remarks

    args is only valid during this method call, do not hold a reference to it.

    See Also
    RegisterInteractable(IXRInteractable)

    OnUnregistered(InteractableUnregisteredEventArgs)

    The XRInteractionManager calls this method when this Interactable is unregistered from it.

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

    Event data containing the Interaction Manager that unregistered this Interactable.

    Remarks

    args is only valid during this method call, do not hold a reference to it.

    See Also
    UnregisterInteractable(IXRInteractable)

    ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase)

    The XRInteractionManager calls this method to update the Interactable.

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

    The update phase this is called during.

    Remarks

    Please see the XRInteractionManager and XRInteractionUpdateOrder.UpdatePhase documentation for more details on update order.

    See Also
    XRInteractionUpdateOrder.UpdatePhase
    ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase)

    Events

    registered

    Unity calls the methods in this invocation list when this Interactable is registered with an XRInteractionManager.

    Declaration
    event Action<InteractableRegisteredEventArgs> registered
    Event Type
    Type Description
    Action<InteractableRegisteredEventArgs>
    Remarks

    The InteractableRegisteredEventArgs passed to each listener is only valid while the event is invoked, do not hold a reference to it.

    See Also
    interactableRegistered

    unregistered

    Unity calls the methods in this invocation list when this Interactable is unregistered from an XRInteractionManager.

    Declaration
    event Action<InteractableUnregisteredEventArgs> unregistered
    Event Type
    Type Description
    Action<InteractableUnregisteredEventArgs>
    Remarks

    The InteractableUnregisteredEventArgs passed to each listener is only valid while the event is invoked, do not hold a reference to it.

    See Also
    interactableUnregistered

    See Also

    XRBaseInteractable
    IXRActivateInteractable
    IXRHoverInteractable
    IXRSelectInteractable
    IXRInteractor
    Back to top
    Terms of use
    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