Class XRBaseInteractor
Abstract base class from which all interactor behaviors derive.
This class hooks into the interaction system (via XRInteraction
Implements
Inherited Members
Namespace: UnityEngine .XR.Interaction.Toolkit.Interactors
Assembly: Unity.XR.Interaction.Toolkit.dll
Syntax
[MovedFrom("UnityEngine.XR.Interaction.Toolkit")]
[SelectionBase]
[DisallowMultipleComponent]
[DefaultExecutionOrder(-99)]
public abstract class XRBaseInteractor : MonoBehaviour, IXRHoverInteractor, IXRSelectInteractor, IXRTargetPriorityInteractor, IXRGroupMember, IXRInteractionStrengthInteractor, IXRInteractor
Properties
allowHover
Defines whether this interactor allows hover events.
Declaration
public bool allowHover { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
A hover exit event will still occur if this value is disabled while hovering.
allowSelect
Defines whether this interactor allows select events.
Declaration
public bool allowSelect { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
A select exit event will still occur if this value is disabled while selecting.
attachTransform
The Transform 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.
containingGroup
The Interaction Group that contains this member.
Declaration
public IXRInteractionGroup containingGroup { get; }
Property Value
Type | Description |
---|---|
IXRInteraction |
disableVisualsWhenBlockedInGroup
Whether to disable Interactor visuals (such as XRInteractor
Declaration
public bool disableVisualsWhenBlockedInGroup { get; set; }
Property Value
Type | Description |
---|---|
bool |
firstInteractableSelected
(Read Only) The first Interactable selected since not having any selection. This Interactor may not currently be selecting the Interactable, which would be the case when it was released while multiple Interactables were selected.
Declaration
public IXRSelectInteractable firstInteractableSelected { get; }
Property Value
Type | Description |
---|---|
IXRSelect |
See Also
handedness
Represents which hand or controller the interactor is associated with.
Declaration
public InteractorHandedness handedness { get; set; }
Property Value
Type | Description |
---|---|
Interactor |
hasHover
(Read Only) Indicates whether this Interactor is currently hovering an Interactable.
Declaration
public bool hasHover { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
In other words, returns whether interactables
Examples
interactablesHovered.Count > 0
See Also
hasSelection
(Read Only) Indicates whether this Interactor is currently selecting an Interactable.
Declaration
public bool hasSelection { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
In other words, returns whether interactables
Examples
interactablesSelected.Count > 0
See Also
hoverEntered
The event that is called when this Interactor begins hovering over an Interactable.
Declaration
public HoverEnterEvent hoverEntered { get; set; }
Property Value
Type | Description |
---|---|
Hover |
Remarks
The Hover
See Also
hoverExited
The event that is called when this Interactor ends hovering over an Interactable.
Declaration
public HoverExitEvent hoverExited { get; set; }
Property Value
Type | Description |
---|---|
Hover |
Remarks
The Hover
See Also
hoverFilters
The list of hover filters in this object. Used as additional hover validations for this Interactor.
Declaration
public IXRFilterList<IXRHoverFilter> hoverFilters { get; }
Property Value
Type | Description |
---|---|
IXRFilter |
Remarks
While processing hover filters, all changes to this list don't have an immediate effect. These changes are
buffered and applied when the processing is finished.
Calling Move
See Also
interactablesHovered
(Read Only) The list of Interactables that are currently being hovered over (may by empty).
Declaration
public List<IXRHoverInteractable> interactablesHovered { get; }
Property Value
Type | Description |
---|---|
List<IXRHover |
Remarks
You should treat this as a read only view of the list and should not modify it.
It is exposed as a List<T> rather than an IRead
See Also
interactablesSelected
(Read Only) The list of Interactables that are currently being selected (may by empty).
Declaration
public List<IXRSelectInteractable> interactablesSelected { get; }
Property Value
Type | Description |
---|---|
List<IXRSelect |
Remarks
This should be treated as a read only view of the list and should not be modified by external callers.
It is exposed as a List<T> rather than an IRead
See Also
interactionLayers
Allows interaction with Interactables whose Interaction Layer Mask overlaps with any Layer in this Interaction Layer Mask.
Declaration
public InteractionLayerMask interactionLayers { get; set; }
Property Value
Type | Description |
---|---|
Interaction |
See Also
interactionManager
The XRInteraction
Declaration
public XRInteractionManager interactionManager { get; set; }
Property Value
Type | Description |
---|---|
XRInteraction |
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 |
---|---|
bool |
isPerformingManualInteraction
Defines whether this interactor is performing a manual interaction or not.
Declaration
public bool isPerformingManualInteraction { get; }
Property Value
Type | Description |
---|---|
bool |
See Also
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 |
---|---|
bool |
keepSelectedTargetValid
Whether to keep selecting an Interactable after initially selecting it even when it is no longer a valid target.
Declaration
public bool keepSelectedTargetValid { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
Return true to make the XRInteraction
A common use for disabling this is for Ray Interactors used for teleportation to make the teleportation Interactable
no longer selected when not currently pointing at it.
largestInteractionStrength
The largest interaction strength value of all interactables this interactor is hovering or selecting.
Declaration
public IReadOnlyBindableVariable<float> largestInteractionStrength { get; }
Property Value
Type | Description |
---|---|
IRead |
selectEntered
The event that is called when this Interactor begins selecting an Interactable.
Declaration
public SelectEnterEvent selectEntered { get; set; }
Property Value
Type | Description |
---|---|
Select |
Remarks
The Select
See Also
selectExited
The event that is called when this Interactor ends selecting an Interactable.
Declaration
public SelectExitEvent selectExited { get; set; }
Property Value
Type | Description |
---|---|
Select |
Remarks
The Select
See Also
selectFilters
The list of select filters in this object. Used as additional select validations for this Interactor.
Declaration
public IXRFilterList<IXRSelectFilter> selectFilters { get; }
Property Value
Type | Description |
---|---|
IXRFilter |
Remarks
While processing select filters, all changes to this list don't have an immediate effect. These changes are
buffered and applied when the processing is finished.
Calling Move
See Also
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 |
---|---|
XRBase |
Remarks
You can use this to change the effective movement type of an Interactable for different
Interactors. An example would be having an Interactable use Velocity
See Also
startingHoverFilters
The hover filters that this object uses to automatically populate the hover
Declaration
public List<Object> startingHoverFilters { get; set; }
Property Value
Remarks
To access and modify the hover filters used after startup, the hover
See Also
startingSelectFilters
The select filters that this object uses to automatically populate the select
Declaration
public List<Object> startingSelectFilters { get; set; }
Property Value
Remarks
To access and modify the select filters used after startup, the select
See Also
startingSelectedInteractable
The Interactable that this Interactor automatically selects at startup (optional, may be null).
Declaration
public XRBaseInteractable startingSelectedInteractable { get; set; }
Property Value
Type | Description |
---|---|
XRBase |
startingTargetFilter
The Target Filter that this Interactor automatically links at startup (optional, may be null).
Declaration
public XRBaseTargetFilter startingTargetFilter { get; set; }
Property Value
Type | Description |
---|---|
XRBase |
Remarks
To modify the Target Filter after startup, the target
See Also
targetFilter
The Target Filter that this Interactor is linked to.
Declaration
public IXRTargetFilter targetFilter { get; set; }
Property Value
Type | Description |
---|---|
IXRTarget |
See Also
targetPriorityMode
Specifies how many Interactables should be monitored in the targets
Declaration
public virtual TargetPriorityMode targetPriorityMode { get; set; }
Property Value
Type | Description |
---|---|
Target |
targetsForSelection
The Interactables with priority for selection in the current frame, some Interactables might be already selected.
This list is sorted by priority (with highest priority first).
How many Interactables appear in this list is configured by the target
Declaration
public virtual List<IXRSelectInteractable> targetsForSelection { get; set; }
Property Value
Type | Description |
---|---|
List<IXRSelect |
Remarks
Unity automatically clears and updates this list every frame if target
Methods
Awake()
See Mono
Declaration
protected virtual void Awake()
CanHover(IXRHoverInteractable)
Determines if the Interactable is valid for hover this frame.
Declaration
public virtual bool CanHover(IXRHoverInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRHover |
interactable | Interactable to check. |
Returns
See Also
CanSelect(IXRSelectInteractable)
Determines if the Interactable is valid for selection this frame.
Declaration
public virtual bool CanSelect(IXRSelectInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRSelect |
interactable | Interactable to check. |
Returns
See Also
CaptureAttachPose(IXRSelectInteractable)
Capture the current Attach Transform pose. This method is automatically called by Unity to capture the pose during the moment of selection.
Declaration
protected void CaptureAttachPose(IXRSelectInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRSelect |
interactable | The specific Interactable as context to get the attachment point for. |
Remarks
Unity automatically calls this method during On
See Also
CreateAttachTransform()
Create a new child GameObject to use as the attach transform if one is not set.
Declaration
protected void CreateAttachTransform()
See Also
EndManualInteraction()
Ends the manually initiated selection of an Interactable.
Declaration
public virtual void EndManualInteraction()
See Also
GetAttachPoseOnSelect(IXRSelectInteractable)
Gets the world position and rotation of the Attach Transform captured during the moment of selection.
Declaration
public Pose GetAttachPoseOnSelect(IXRSelectInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRSelect |
interactable | The specific Interactable as context to get the attachment point for. |
Returns
Type | Description |
---|---|
Pose | Returns the world pose of the attachment point during the moment of selection, and otherwise the identity Pose if it was not selected during the current selection stack. |
See Also
GetAttachTransform(IXRInteractable)
Gets the Transform that is used as the attachment point for a given Interactable.
Declaration
public virtual Transform GetAttachTransform(IXRInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRInteractable | interactable | The specific Interactable as context to get the attachment point for. |
Returns
Remarks
This should typically return the Transform of a child GameObject or the transform itself.
See Also
GetInteractionStrength(IXRInteractable)
Gets the interaction strength between the given interactable and this interactor.
Declaration
public float GetInteractionStrength(IXRInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRInteractable | interactable | The specific interactable to get the interaction strength between. |
Returns
Type | Description |
---|---|
float | Returns a value |
GetLocalAttachPoseOnSelect(IXRSelectInteractable)
Gets the local position and rotation of the Attach Transform captured during the moment of selection.
Declaration
public Pose GetLocalAttachPoseOnSelect(IXRSelectInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRSelect |
interactable | The specific Interactable as context to get the attachment point for. |
Returns
Type | Description |
---|---|
Pose | Returns the local pose of the attachment point during the moment of selection, and otherwise the identity Pose if it was not selected during the current selection stack. |
See Also
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
public virtual 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.
IsHovering(IXRHoverInteractable)
Determines whether this Interactor is currently hovering the Interactable.
Declaration
public bool IsHovering(IXRHoverInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRHover |
interactable | Interactable to check. |
Returns
Type | Description |
---|---|
bool | Returns true if this Interactor is currently hovering the Interactable. Otherwise, returns false. |
Remarks
In other words, returns whether interactablesinteractable
.
See Also
IsHovering(IXRInteractable)
Determines whether this Interactor is currently hovering the Interactable.
Declaration
protected bool IsHovering(IXRInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRInteractable | interactable | Interactable to check. |
Returns
Type | Description |
---|---|
bool | Returns true if this Interactor is currently hovering the Interactable. Otherwise, returns false. |
Remarks
In other words, returns whether interactablesinteractable
.
See Also
IsSelecting(IXRInteractable)
Determines whether this Interactor is currently selecting the Interactable.
Declaration
protected bool IsSelecting(IXRInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRInteractable | interactable | Interactable to check. |
Returns
Type | Description |
---|---|
bool | Returns true if this Interactor is currently selecting the Interactable. Otherwise, returns false. |
Remarks
In other words, returns whether interactablesinteractable
.
See Also
IsSelecting(IXRSelectInteractable)
Determines whether this Interactor is currently selecting the Interactable.
Declaration
public bool IsSelecting(IXRSelectInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRSelect |
interactable | Interactable to check. |
Returns
Type | Description |
---|---|
bool | Returns true if this Interactor is currently selecting the Interactable. Otherwise, returns false. |
Remarks
In other words, returns whether interactablesinteractable
.
See Also
OnDestroy()
See Mono
Declaration
protected virtual void OnDestroy()
OnDisable()
See Mono
Declaration
protected virtual void OnDisable()
OnEnable()
See Mono
Declaration
protected virtual void OnEnable()
OnHoverEntered(HoverEnterEventArgs)
The XRInteraction
Declaration
protected virtual void OnHoverEntered(HoverEnterEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Hover |
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
OnHoverEntering(HoverEnterEventArgs)
The XRInteraction
Declaration
protected virtual void OnHoverEntering(HoverEnterEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Hover |
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)
The XRInteraction
Declaration
protected virtual void OnHoverExited(HoverExitEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Hover |
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
OnHoverExiting(HoverExitEventArgs)
The XRInteraction
Declaration
protected virtual void OnHoverExiting(HoverExitEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Hover |
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
OnRegistered(InteractorRegisteredEventArgs)
The XRInteraction
Declaration
protected virtual void OnRegistered(InteractorRegisteredEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Interactor |
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
OnSelectEntered(SelectEnterEventArgs)
The XRInteraction
Declaration
protected virtual void OnSelectEntered(SelectEnterEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Select |
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
OnSelectEntering(SelectEnterEventArgs)
The XRInteraction
Declaration
protected virtual void OnSelectEntering(SelectEnterEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Select |
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)
The XRInteraction
Declaration
protected virtual void OnSelectExited(SelectExitEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Select |
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
OnSelectExiting(SelectExitEventArgs)
The XRInteraction
Declaration
protected virtual void OnSelectExiting(SelectExitEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Select |
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
OnUnregistered(InteractorUnregisteredEventArgs)
The XRInteraction
Declaration
protected virtual void OnUnregistered(InteractorUnregisteredEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Interactor |
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
PreprocessInteractor(UpdatePhase)
The XRInteraction
Declaration
public virtual void PreprocessInteractor(XRInteractionUpdateOrder.UpdatePhase updatePhase)
Parameters
Type | Name | Description |
---|---|---|
XRInteraction |
updatePhase | The update phase this is called during. |
Remarks
Please see the XRInteraction
See Also
ProcessHoverFilters(IXRHoverInteractable)
Returns the processing value of the filters in hover
Declaration
protected bool ProcessHoverFilters(IXRHoverInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRHover |
interactable | The Interactable to be validated by the hover filters. |
Returns
Type | Description |
---|---|
bool | Returns true if all processed filters also return true, or if
hover |
ProcessInteractionStrength(UpdatePhase)
The XRInteraction
Declaration
protected virtual void ProcessInteractionStrength(XRInteractionUpdateOrder.UpdatePhase updatePhase)
Parameters
Type | Name | Description |
---|---|---|
XRInteraction |
updatePhase | The update phase during which this method is called. |
See Also
ProcessInteractor(UpdatePhase)
The XRInteraction
Declaration
public virtual void ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase updatePhase)
Parameters
Type | Name | Description |
---|---|---|
XRInteraction |
updatePhase | The update phase this is called during. |
Remarks
Please see the XRInteraction
See Also
ProcessSelectFilters(IXRSelectInteractable)
Returns the processing value of the filters in select
Declaration
protected bool ProcessSelectFilters(IXRSelectInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRSelect |
interactable | The Interactor to be validated by the select filters. |
Returns
Type | Description |
---|---|
bool | Returns true if all processed filters also return true, or if
select |
Reset()
See Mono
Declaration
[Conditional("UNITY_EDITOR")]
protected virtual void Reset()
Start()
See Mono
Declaration
protected virtual void Start()
StartManualInteraction(IXRSelectInteractable)
Manually initiate selection of an Interactable.
Declaration
public virtual void StartManualInteraction(IXRSelectInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRSelect |
interactable | Interactable that is being selected. |
See Also
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<Interactor |
Remarks
The Interactor
See Also
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<Interactor |
Remarks
The Interactor