docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IXRInteractor

    An interface that represents an Interactor component that controls how a GameObject interacts with an Interactable component. An example is a Ray Interactor which uses ray casting to find valid Interactable objects to manipulate.

    Namespace: UnityEngine.XR.Interaction.Toolkit.Interactors
    Assembly: Unity.XR.Interaction.Toolkit.dll
    Syntax
    [MovedFrom("UnityEngine.XR.Interaction.Toolkit")]
    public interface IXRInteractor
    Remarks

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

    Properties

    handedness

    (Read Only) Represents which hand or controller the interactor is associated with.

    Declaration
    InteractorHandedness handedness { get; }
    Property Value
    Type Description
    InteractorHandedness
    See Also
    InteractorHandedness

    interactionLayers

    (Read Only) Allows interaction with Interactables 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 Interactor.

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

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

    See Also
    XRBaseInteractor
    IXRActivateInteractor
    IXRHoverInteractor
    IXRSelectInteractor
    IXRGroupMember
    IXRInteractable

    Methods

    GetAttachTransform(IXRInteractable)

    Gets the Transform that is used as the attachment point for a given Interactable.

    Declaration
    Transform GetAttachTransform(IXRInteractable interactable)
    Parameters
    Type Name Description
    IXRInteractable interactable

    The specific Interactable 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(IXRInteractor)

    GetValidTargets(List<IXRInteractable>)

    Retrieve the list of Interactables that this Interactor could possibly interact with this frame. This list is sorted by priority (with highest priority first).

    Declaration
    void GetValidTargets(List<IXRInteractable> targets)
    Parameters
    Type Name Description
    List<IXRInteractable> targets

    The results list to populate with Interactables that are valid for selection or hover.

    Remarks

    When implementing this method, Unity expects you to clear targets before adding to it.

    See Also
    XRBaseInteractor
    IXRActivateInteractor
    IXRHoverInteractor
    IXRSelectInteractor
    IXRGroupMember
    IXRInteractable

    OnRegistered(InteractorRegisteredEventArgs)

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

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

    Event data containing the Interaction Manager that registered this Interactor.

    Remarks

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

    See Also
    RegisterInteractor(IXRInteractor)

    OnUnregistered(InteractorUnregisteredEventArgs)

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

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

    Event data containing the Interaction Manager that unregistered this Interactor.

    Remarks

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

    See Also
    UnregisterInteractor(IXRInteractor)

    PreprocessInteractor(UpdatePhase)

    The XRInteractionManager or containing IXRInteractionGroup calls this method to update the Interactor before interaction events occur. Interactors should use this method to do tasks like determine their valid targets.

    Declaration
    void PreprocessInteractor(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(UpdatePhase)

    The XRInteractionManager or containing IXRInteractionGroup calls this method to update the Interactor after interaction events occur.

    Declaration
    void ProcessInteractor(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
    ProcessInteractable(UpdatePhase)

    Events

    registered

    Calls the methods in its invocation list when this Interactor is registered with an Interaction Manager.

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

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

    See Also
    interactorRegistered

    unregistered

    Calls the methods in its invocation list when this Interactor is unregistered from an Interaction Manager.

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

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

    See Also
    interactorUnregistered

    Extension Methods

    XRInteractorExtensions.IsBlockedByInteractionWithinGroup(IXRInteractor)

    See Also

    XRBaseInteractor
    IXRActivateInteractor
    IXRHoverInteractor
    IXRSelectInteractor
    IXRGroupMember
    IXRInteractable
    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)