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.
Inherited Members
Namespace: UnityEngine.XR.Interaction.Toolkit
Syntax
[SelectionBase]
[DisallowMultipleComponent]
[DefaultExecutionOrder(-99)]
public abstract class XRBaseInteractor : MonoBehaviour
Properties
allowHover
Declaration
public bool allowHover { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
allowSelect
Declaration
public bool allowSelect { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
attachTransform
The attach transform that is used as an attach point for interactables.
Declaration
public Transform attachTransform { get; set; }
Property Value
Type | Description |
---|---|
Transform |
Remarks
Automatically instantiated and set in Awake(). Setting this will not automatically destroy the previous object.
enableInteractions
Declaration
public bool enableInteractions { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
hoverTargets
Target interactables that are currently being hovered over (may by empty).
Declaration
protected List<XRBaseInteractable> hoverTargets { get; }
Property Value
Type | Description |
---|---|
List<XRBaseInteractable> |
interactionLayerMask
Only interactables with this layer mask will respond to this interactor.
Declaration
public LayerMask interactionLayerMask { get; set; }
Property Value
Type | Description |
---|---|
LayerMask |
interactionManager
The XRInteractionManager that this interactor will communicate with.
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
Declaration
public bool isPerformingManualInteraction { get; }
Property Value
Type | Description |
---|---|
Boolean |
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
Declaration
[Obsolete("onHoverEnter has been deprecated. Use onHoverEntered instead. (UnityUpgradable) -> onHoverEntered")]
public XRInteractorEvent onHoverEnter { get; }
Property Value
Type | Description |
---|---|
XRInteractorEvent |
onHoverEntered
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
Declaration
[Obsolete("onHoverExit has been deprecated. Use onHoverExited instead. (UnityUpgradable) -> onHoverExited")]
public XRInteractorEvent onHoverExit { get; }
Property Value
Type | Description |
---|---|
XRInteractorEvent |
onHoverExited
Gets or sets the event that is called when this interactor stops hovering over an interactable.
Declaration
public XRInteractorEvent onHoverExited { get; set; }
Property Value
Type | Description |
---|---|
XRInteractorEvent |
onSelectEnter
Declaration
[Obsolete("onSelectEnter has been deprecated. Use onSelectEntered instead. (UnityUpgradable) -> onSelectEntered")]
public XRInteractorEvent onSelectEnter { get; }
Property Value
Type | Description |
---|---|
XRInteractorEvent |
onSelectEntered
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
Declaration
[Obsolete("onSelectExit has been deprecated. Use onSelectExited instead. (UnityUpgradable) -> onSelectExited")]
public XRInteractorEvent onSelectExit { get; }
Property Value
Type | Description |
---|---|
XRInteractorEvent |
onSelectExited
Gets or sets the event that is called when this interactor stops 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.
Declaration
public virtual bool requireSelectExclusive { get; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
That is, this interactor will only be selected if exactly one interactor is trying to select it.
selectedInteractableMovementTypeOverride
(Read Only) Overriding movement type of the selected interactable's movement.
Declaration
public virtual XRBaseInteractable.MovementType? selectedInteractableMovementTypeOverride { get; }
Property Value
Type | Description |
---|---|
Nullable<XRBaseInteractable.MovementType> |
selectTarget
Selected interactable for this interactor (may be null).
Declaration
public XRBaseInteractable selectTarget { get; protected set; }
Property Value
Type | Description |
---|---|
XRBaseInteractable |
startingSelectedInteractable
The initial interactable that is selected by this interactor at startup (optional, may be null).
Declaration
public XRBaseInteractable startingSelectedInteractable { get; set; }
Property Value
Type | Description |
---|---|
XRBaseInteractable |
Methods
Awake()
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. |
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. |
EndManualInteraction()
Ends the manually initiated selection of an interactable.
Declaration
public virtual void EndManualInteraction()
See Also
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 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.
Declaration
public abstract void GetValidTargets(List<XRBaseInteractable> validTargets)
Parameters
Type | Name | Description |
---|---|---|
List<XRBaseInteractable> | validTargets | Populated List of interactables that are valid for selection or hover. |
OnDestroy()
Declaration
protected virtual void OnDestroy()
OnDisable()
Declaration
protected virtual void OnDisable()
OnEnable()
Declaration
protected virtual void OnEnable()
OnHoverEntered(XRBaseInteractable)
This method is called by the interaction manager when the interactor first initiates hovering over an interactable.
Declaration
protected virtual void OnHoverEntered(XRBaseInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractable | interactable | Interactable that is being hovered over. |
See Also
OnHoverEntering(XRBaseInteractable)
This method is called by the interaction manager right before the interactor first initiates hovering over an interactable.
Declaration
protected virtual void OnHoverEntering(XRBaseInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractable | interactable | Interactable that is being hovered over. |
See Also
OnHoverExited(XRBaseInteractable)
This method is called by the interaction manager when the interactor ends hovering over an interactable.
Declaration
protected virtual void OnHoverExited(XRBaseInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractable | interactable | Interactable that is no longer hovered over. |
See Also
OnHoverExiting(XRBaseInteractable)
This method is called by the interaction manager right before the interactor ends hovering over an interactable.
Declaration
protected virtual void OnHoverExiting(XRBaseInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractable | interactable | Interactable that is no longer hovered over. |
See Also
OnSelectEntered(XRBaseInteractable)
This method is called by the interaction manager when the interactor first initiates selection of an interactable.
Declaration
protected virtual void OnSelectEntered(XRBaseInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractable | interactable | Interactable that is being selected. |
See Also
OnSelectEntering(XRBaseInteractable)
This method is called by the interaction manager right before the first initiates selection of an interactable.
Declaration
protected virtual void OnSelectEntering(XRBaseInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractable | interactable | Interactable that is being selected. |
See Also
OnSelectExited(XRBaseInteractable)
This method is called by the interaction manager when the interactor ends selection of an interactable.
Declaration
protected virtual void OnSelectExited(XRBaseInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractable | interactable | Interactable that is no longer selected. |
See Also
OnSelectExiting(XRBaseInteractable)
This method is called by the interaction manager right before the interactor ends selection of an interactable.
Declaration
protected virtual void OnSelectExiting(XRBaseInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractable | interactable | Interactable that is no longer selected. |
See Also
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 |
Reset()
Declaration
[Conditional("UNITY_EDITOR")]
protected virtual void Reset()
Start()
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. |