docs.unity3d.com
    Show / Hide Table of Contents

    Class XRBaseInteractor

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

    Inheritance
    Object
    XRBaseInteractor
    ARGestureInteractor
    XRBaseControllerInteractor
    XRSocketInteractor
    Namespace: UnityEngine.XR.Interaction.Toolkit
    Syntax
    public abstract class XRBaseInteractor : MonoBehaviour

    Properties

    allowHover

    Defines whether this interactor allows hover events.

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

    allowSelect

    Defines whether this interactor allows select events.

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

    attachTransform

    The that is used as the attach point for Interactables.

    Declaration
    public Transform attachTransform { get; set; }
    Property Value
    Type Description
    Transform
    Remarks

    Automatically instantiated and set in Awake() if null. Setting this will not automatically destroy the previous object.

    enableInteractions

    (Deprecated) Defines whether interactions are enabled or not.

    Declaration
    public bool enableInteractions { get; set; }
    Property Value
    Type Description
    Boolean
    Remarks
    enableInteractions = value; is a convenience property for:
    allowHover = value;
    allowSelect = value;

    hoverEntered

    Gets or sets the event that is called when this Interactor begins hovering over an Interactable.

    Declaration
    public HoverEnterEvent hoverEntered { get; set; }
    Property Value
    Type Description
    HoverEnterEvent
    Remarks

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

    See Also
    hoverExited

    hoverExited

    Gets or sets the event that is called when this Interactor ends hovering over an Interactable.

    Declaration
    public HoverExitEvent hoverExited { get; set; }
    Property Value
    Type Description
    HoverExitEvent
    Remarks

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

    See Also
    hoverEntered

    hoverTargets

    Target interactables that are currently being hovered over (may by empty).

    Declaration
    protected List<XRBaseInteractable> hoverTargets { get; }
    Property Value
    Type Description
    List<XRBaseInteractable>
    See Also
    hoveringInteractors

    interactionLayerMask

    Allows interaction with Interactables whose Interaction Layer Mask overlaps with any layer in this Interaction Layer Mask.

    Declaration
    public LayerMask interactionLayerMask { get; set; }
    Property Value
    Type Description
    LayerMask
    See Also
    interactionLayerMask
    CanHover(XRBaseInteractable)
    CanSelect(XRBaseInteractable)

    interactionManager

    The XRInteractionManager that this Interactor will communicate with (will find one if null).

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

    isHoverActive

    (Read Only) Indicates whether this interactor is in a state where it could hover.

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

    isPerformingManualInteraction

    Defines whether this interactor is performing a manual interaction or not.

    Declaration
    public bool isPerformingManualInteraction { get; }
    Property Value
    Type Description
    Boolean
    See Also
    StartManualInteraction(XRBaseInteractable)
    EndManualInteraction()

    isSelectActive

    (Read Only) Indicates whether this interactor is in a state where it could select.

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

    onHoverEnter

    (Deprecated) Gets or sets the event that is called when this Interactor begins hovering over an Interactable.

    Declaration
    public XRInteractorEvent onHoverEnter { get; }
    Property Value
    Type Description
    XRInteractorEvent

    onHoverEntered

    (Deprecated) Gets or sets the event that is called when this Interactor begins hovering over an Interactable.

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

    onHoverExit

    (Deprecated) Gets or sets the event that is called when this Interactor ends hovering over an Interactable.

    Declaration
    public XRInteractorEvent onHoverExit { get; }
    Property Value
    Type Description
    XRInteractorEvent

    onHoverExited

    (Deprecated) Gets or sets the event that is called when this Interactor ends hovering over an Interactable.

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

    onSelectEnter

    (Deprecated) Gets or sets the event that is called when this Interactor begins selecting an Interactable.

    Declaration
    public XRInteractorEvent onSelectEnter { get; }
    Property Value
    Type Description
    XRInteractorEvent

    onSelectEntered

    (Deprecated) Gets or sets the event that is called when this Interactor begins selecting an Interactable.

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

    onSelectExit

    (Deprecated) Gets or sets the event that is called when this Interactor ends selecting an Interactable.

    Declaration
    public XRInteractorEvent onSelectExit { get; }
    Property Value
    Type Description
    XRInteractorEvent

    onSelectExited

    (Deprecated) Gets or sets the event that is called when this Interactor ends selecting an Interactable.

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

    requireSelectExclusive

    (Read Only) Indicates whether this Interactor requires exclusive selection of an Interactable to select it.

    Declaration
    public virtual bool requireSelectExclusive { get; }
    Property Value
    Type Description
    Boolean
    Remarks

    When true, this Interactor will only select an Interactable when that Interactable is not currently selected. When false, a selected Interactable will first be deselected before being selected by this Interactor.

    selectedInteractableMovementTypeOverride

    (Read Only) Overriding movement type of the selected Interactable's movement. By default, this does not override the movement type.

    Declaration
    public virtual XRBaseInteractable.MovementType? selectedInteractableMovementTypeOverride { get; }
    Property Value
    Type Description
    Nullable<XRBaseInteractable.MovementType>
    Remarks

    This can be used to change the effective movement type of an Interactable for different Interactors. An example would be having an Interactable use VelocityTracking so it does not move through geometry with a Collider when interacting with it using a Ray or Direct Interactor, but have a Socket Interactor override the movement type to be Instantaneous for reduced movement latency.

    See Also
    movementType

    selectEntered

    Gets or sets the event that is called when this Interactor begins selecting an Interactable.

    Declaration
    public SelectEnterEvent selectEntered { get; set; }
    Property Value
    Type Description
    SelectEnterEvent
    Remarks

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

    See Also
    selectExited

    selectExited

    Gets or sets the event that is called when this Interactor ends selecting an Interactable.

    Declaration
    public SelectExitEvent selectExited { get; set; }
    Property Value
    Type Description
    SelectExitEvent
    Remarks

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

    See Also
    selectEntered

    selectTarget

    Selected interactable for this interactor (may be null).

    Declaration
    public XRBaseInteractable selectTarget { get; protected set; }
    Property Value
    Type Description
    XRBaseInteractable
    See Also
    selectingInteractor

    startingSelectedInteractable

    The Interactable that this Interactor will automatically select at startup (optional, may be null).

    Declaration
    public XRBaseInteractable startingSelectedInteractable { get; set; }
    Property Value
    Type Description
    XRBaseInteractable

    Methods

    Awake()

    See .

    Declaration
    protected virtual void Awake()

    CanHover(XRBaseInteractable)

    Determines if the interactable is valid for hover this frame.

    Declaration
    public virtual bool CanHover(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable to check.

    Returns
    Type Description
    Boolean

    Returns true if the interactable can be hovered over this frame.

    See Also
    IsHoverableBy(XRBaseInteractor)

    CanSelect(XRBaseInteractable)

    Determines if the interactable is valid for selection this frame.

    Declaration
    public virtual bool CanSelect(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable to check.

    Returns
    Type Description
    Boolean

    Returns true if the interactable can be selected this frame.

    See Also
    IsSelectableBy(XRBaseInteractor)

    EndManualInteraction()

    Ends the manually initiated selection of an Interactable.

    Declaration
    public virtual void EndManualInteraction()
    See Also
    StartManualInteraction(XRBaseInteractable)

    GetHoverTargets(List<XRBaseInteractable>)

    Retrieves a copy of the list of target interactables that are currently being hovered over.

    Declaration
    public void GetHoverTargets(List<XRBaseInteractable> targets)
    Parameters
    Type Name Description
    List<XRBaseInteractable> targets

    The results list to store hover targets into.

    Remarks

    Clears targets before adding to it.

    GetValidTargets(List<XRBaseInteractable>)

    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
    public abstract void GetValidTargets(List<XRBaseInteractable> targets)
    Parameters
    Type Name Description
    List<XRBaseInteractable> targets

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

    OnDestroy()

    See .

    Declaration
    protected virtual void OnDestroy()

    OnDisable()

    See .

    Declaration
    protected virtual void OnDisable()

    OnEnable()

    See .

    Declaration
    protected virtual void OnEnable()

    OnHoverEntered(HoverEnterEventArgs)

    This method is called by the Interaction Manager when the Interactor first initiates hovering over an Interactable in a second pass.

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

    Event data containing the Interactable that is being hovered over.

    Remarks

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

    See Also
    OnHoverExited(HoverExitEventArgs)

    OnHoverEntered(XRBaseInteractable)

    (Deprecated) This method is called by the Interaction Manager when the Interactor first initiates hovering over an Interactable in a second pass.

    Declaration
    protected virtual void OnHoverEntered(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is being hovered over.

    See Also
    OnHoverExited(XRBaseInteractable)

    OnHoverEntering(HoverEnterEventArgs)

    This method is called by the Interaction Manager right before the Interactor first initiates hovering over an Interactable in a first pass.

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

    Event data containing the Interactable that is being hovered over.

    Remarks

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

    See Also
    OnHoverEntered(HoverEnterEventArgs)

    OnHoverEntering(XRBaseInteractable)

    (Deprecated) This method is called by the Interaction Manager right before the Interactor first initiates hovering over an Interactable in a first pass.

    Declaration
    protected virtual void OnHoverEntering(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is being hovered over.

    See Also
    OnHoverEntered(XRBaseInteractable)

    OnHoverExited(HoverExitEventArgs)

    This method is called by the Interaction Manager when the Interactor ends hovering over an Interactable in a second pass.

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

    Event data containing the Interactable that is no longer hovered over.

    Remarks

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

    See Also
    OnHoverEntered(HoverEnterEventArgs)

    OnHoverExited(XRBaseInteractable)

    (Deprecated) This method is called by the Interaction Manager when the Interactor ends hovering over an Interactable in a second pass.

    Declaration
    protected virtual void OnHoverExited(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is no longer hovered over.

    See Also
    OnHoverEntered(XRBaseInteractable)

    OnHoverExiting(HoverExitEventArgs)

    This method is called by the Interaction Manager right before the Interactor ends hovering over an Interactable in a first pass.

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

    Event data containing the Interactable that is no longer hovered over.

    Remarks

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

    See Also
    OnHoverExited(HoverExitEventArgs)

    OnHoverExiting(XRBaseInteractable)

    (Deprecated) This method is called by the Interaction Manager right before the Interactor ends hovering over an Interactable in a first pass.

    Declaration
    protected virtual void OnHoverExiting(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is no longer hovered over.

    See Also
    OnHoverExited(XRBaseInteractable)

    OnRegistered(InteractorRegisteredEventArgs)

    This method is called by the Interaction Manager when this Interactor is registered with it.

    Declaration
    protected virtual 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(XRBaseInteractor)

    OnSelectEntered(SelectEnterEventArgs)

    This method is called by the Interaction Manager when the Interactor first initiates selection of an Interactable in a second pass.

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

    Event data containing the Interactable that is being selected.

    Remarks

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

    See Also
    OnSelectExited(SelectExitEventArgs)

    OnSelectEntered(XRBaseInteractable)

    (Deprecated) This method is called by the Interaction Manager when the Interactor first initiates selection of an Interactable in a second pass.

    Declaration
    protected virtual void OnSelectEntered(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is being selected.

    See Also
    OnSelectExited(XRBaseInteractable)

    OnSelectEntering(SelectEnterEventArgs)

    This method is called by the Interaction Manager right before the Interactor first initiates selection of an Interactable in a first pass.

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

    Event data containing the Interactable that is being selected.

    Remarks

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

    See Also
    OnSelectEntered(SelectEnterEventArgs)

    OnSelectEntering(XRBaseInteractable)

    (Deprecated) This method is called by the Interaction Manager right before the Interactor first initiates selection of an Interactable in a first pass.

    Declaration
    protected virtual void OnSelectEntering(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is being selected.

    See Also
    OnSelectEntered(XRBaseInteractable)

    OnSelectExited(SelectExitEventArgs)

    This method is called by the Interaction Manager when the Interactor ends selection of an Interactable in a second pass.

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

    Event data containing the Interactable that is no longer selected.

    Remarks

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

    See Also
    OnSelectEntered(SelectEnterEventArgs)

    OnSelectExited(XRBaseInteractable)

    (Deprecated) This method is called by the Interaction Manager when the Interactor ends selection of an Interactable in a second pass.

    Declaration
    protected virtual void OnSelectExited(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is no longer selected.

    See Also
    OnSelectEntered(XRBaseInteractable)

    OnSelectExiting(SelectExitEventArgs)

    This method is called by the Interaction Manager right before the Interactor ends selection of an Interactable in a first pass.

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

    Event data containing the Interactable that is no longer selected.

    Remarks

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

    See Also
    OnSelectExited(SelectExitEventArgs)

    OnSelectExiting(XRBaseInteractable)

    (Deprecated) This method is called by the Interaction Manager right before the Interactor ends selection of an Interactable in a first pass.

    Declaration
    protected virtual void OnSelectExiting(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is no longer selected.

    See Also
    OnSelectExited(XRBaseInteractable)

    OnUnregistered(InteractorUnregisteredEventArgs)

    This method is called by the Interaction Manager when this Interactor is unregistered from it.

    Declaration
    protected virtual 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(XRBaseInteractor)

    ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase)

    This method is called by the Interaction Manager to update the Interactor. Please see the Interaction Manager documentation for more details on update order.

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

    The update phase this is called during.

    Reset()

    See .

    Declaration
    protected virtual void Reset()

    Start()

    See .

    Declaration
    protected virtual void Start()

    StartManualInteraction(XRBaseInteractable)

    Manually initiate selection of an Interactable.

    Declaration
    public virtual void StartManualInteraction(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is being selected.

    See Also
    EndManualInteraction()

    Events

    registered

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

    Declaration
    public 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
    public 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
    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