Class XRBaseInteractor
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.
Namespace: UnityEngine.XR.Interaction.Toolkit
Syntax
public abstract class XRBaseInteractor : MonoBehaviour
Fields
m_HoverTargets
Declaration
protected List<XRBaseInteractable> m_HoverTargets
Field Value
Type | Description |
---|---|
List<XRBaseInteractable> |
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
Gets or sets the attach transform that is used as an attach point for interactables. Note: setting this will not automatically destroy the previous attach transform object.
Declaration
public Transform attachTransform { get; }
Property Value
Type | Description |
---|---|
Transform |
enableInteractions
Declaration
public bool enableInteractions { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
interactionLayerMask
Gets layer mask that is used to filter the interactables that can be interacted with.
Declaration
public LayerMask interactionLayerMask { get; }
Property Value
Type | Description |
---|---|
LayerMask |
InteractionLayerMask
Gets or sets interaction layer mask. Only interactables with this layer mask will respond to this interactor.
Declaration
public LayerMask InteractionLayerMask { get; set; }
Property Value
Type | Description |
---|---|
LayerMask |
interactionManager
Gets or sets Interaction Manager.
Declaration
public XRInteractionManager interactionManager { get; set; }
Property Value
Type | Description |
---|---|
XRInteractionManager |
isHoverActive
Gets whether this interactor is in a state where it could hover.
Declaration
public virtual bool isHoverActive { get; }
Property Value
Type | Description |
---|---|
Boolean |
isSelectActive
Gets whether this interactor is in a state where it could select.
Declaration
public virtual bool isSelectActive { get; }
Property Value
Type | Description |
---|---|
Boolean |
onHoverEnter
Gets or sets the event that is called when this interactor begins hovering over an interactable.
Declaration
public XRInteractorEvent onHoverEnter { get; set; }
Property Value
Type | Description |
---|---|
XRInteractorEvent |
onHoverExit
Gets or sets the event that is called when this interactor stops hovering over an interactable.
Declaration
public XRInteractorEvent onHoverExit { get; set; }
Property Value
Type | Description |
---|---|
XRInteractorEvent |
onSelectEnter
Gets or sets the event that is called when this interactor begins selecting an interactable.
Declaration
public XRInteractorEvent onSelectEnter { get; set; }
Property Value
Type | Description |
---|---|
XRInteractorEvent |
onSelectExit
Gets or sets the event that is called when this interactor stops selecting an interactable.
Declaration
public XRInteractorEvent onSelectExit { get; set; }
Property Value
Type | Description |
---|---|
XRInteractorEvent |
overrideSelectedInteractableMovement
Gets whether this interactor can override the movement type of the currently selected interactable.
Declaration
public virtual bool overrideSelectedInteractableMovement { get; }
Property Value
Type | Description |
---|---|
Boolean |
requireSelectExclusive
Gets if this interactor requires exclusive selection of an interactable.
Declaration
public virtual bool requireSelectExclusive { get; }
Property Value
Type | Description |
---|---|
Boolean |
selectedInteractableMovementTypeOverride
Gets the movement type to use when overriding the selected interactable's movement.
Declaration
public virtual XRBaseInteractable.MovementType? selectedInteractableMovementTypeOverride { get; }
Property Value
Type | Description |
---|---|
Nullable<XRBaseInteractable.MovementType> |
selectTarget
Gets selected interactable for this interactor.
Declaration
public XRBaseInteractable selectTarget { get; }
Property Value
Type | Description |
---|---|
XRBaseInteractable |
startingSelectedInteractable
Gets initial interactable that is selected by this interactor (may be null).
Declaration
public XRBaseInteractable startingSelectedInteractable { get; }
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 |
|
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 |
|
GetHoverTargets(List<XRBaseInteractable>)
Declaration
public void GetHoverTargets(List<XRBaseInteractable> hoverTargets)
Parameters
Type | Name | Description |
---|---|---|
List<XRBaseInteractable> | hoverTargets |
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. |
OnDisable()
Declaration
protected virtual void OnDisable()
OnEnable()
Declaration
protected virtual void OnEnable()
OnHoverEnter(XRBaseInteractable)
This method is called by the interaction manager when the interactor first initiates hovering over an interactable.
Declaration
protected virtual void OnHoverEnter(XRBaseInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractable | interactable | Interactable that is being hovered over. |
OnHoverExit(XRBaseInteractable)
This method is called by the interaction manager when the interactor ends hovering over an interactable.
Declaration
protected virtual void OnHoverExit(XRBaseInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractable | interactable | Interactable that is no longer hovered over. |
OnSelectEnter(XRBaseInteractable)
This method is called by the interaction manager when the interactor first initiates selection of an interactable.
Declaration
protected virtual void OnSelectEnter(XRBaseInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractable | interactable | Interactable that is being selected. |
OnSelectExit(XRBaseInteractable)
This method is called by the interaction manager when the interactor ends selection of an interactable.
Declaration
protected virtual void OnSelectExit(XRBaseInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractable | interactable | Interactable that is no longer selected. |
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
protected virtual void Reset()
Start()
Declaration
protected void Start()