Class XRBaseControllerInteractor
Abstract base class from which all interactors that are controller-driven derive. This class hooks into the interaction system (via XRInteractionManager) and provides base virtual methods for handling hover and selection. Additionally, this class provides functionality for checking the controller's selection status and hiding the controller on selection.
Inheritance
Implements
Inherited Members
Namespace: UnityEngine.XR.Interaction.Toolkit
Assembly: Unity.XR.Interaction.Toolkit.dll
Syntax
public abstract class XRBaseControllerInteractor : XRBaseInteractor, IXRHoverInteractor, IXRSelectInteractor, IXRTargetPriorityInteractor, IXRGroupMember, IXRInteractionStrengthInteractor, IXRActivateInteractor, IXRInteractor
Properties
allowActivate
Defines whether this interactor allows sending activate and deactivate events.
Declaration
public bool allowActivate { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
allowHoverAudioWhileSelecting
Controls whether Unity allows playing an AudioClip from a Hover event if the Hovered Interactable is currently Selected by this Interactor.
Declaration
public bool allowHoverAudioWhileSelecting { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
allowHoverHapticsWhileSelecting
Controls whether Unity allows playing haptics from a Hover event if the Hovered Interactable is currently Selected by this Interactor.
Declaration
public bool allowHoverHapticsWhileSelecting { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
allowHoveredActivate
Controls whether to send activate and deactivate events to interactables that this interactor is hovered over but not selected when there is no current selection. By default, the interactor will only send activate and deactivate events to interactables that it's selected.
Declaration
public bool allowHoveredActivate { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
audioClipForOnHoverCanceled
The AudioClip Unity plays on Hover Canceled.
Declaration
public AudioClip audioClipForOnHoverCanceled { get; set; }
Property Value
Type | Description |
---|---|
AudioClip |
See Also
audioClipForOnHoverEntered
The AudioClip Unity plays on Hover Entered.
Declaration
public AudioClip audioClipForOnHoverEntered { get; set; }
Property Value
Type | Description |
---|---|
AudioClip |
See Also
audioClipForOnHoverExited
The AudioClip Unity plays on Hover Exited.
Declaration
public AudioClip audioClipForOnHoverExited { get; set; }
Property Value
Type | Description |
---|---|
AudioClip |
See Also
audioClipForOnSelectCanceled
The AudioClip Unity plays on Select Canceled.
Declaration
public AudioClip audioClipForOnSelectCanceled { get; set; }
Property Value
Type | Description |
---|---|
AudioClip |
See Also
audioClipForOnSelectEntered
The AudioClip Unity plays on Select Entered.
Declaration
public AudioClip audioClipForOnSelectEntered { get; set; }
Property Value
Type | Description |
---|---|
AudioClip |
See Also
audioClipForOnSelectExited
The AudioClip Unity plays on Select Exited.
Declaration
public AudioClip audioClipForOnSelectExited { get; set; }
Property Value
Type | Description |
---|---|
AudioClip |
See Also
hapticHoverCancelDuration
The Haptics duration (in seconds) Unity plays on Hover Canceled.
Declaration
public float hapticHoverCancelDuration { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
hapticHoverCancelIntensity
The Haptics intensity Unity plays on Hover Canceled.
Declaration
public float hapticHoverCancelIntensity { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
hapticHoverEnterDuration
The Haptics duration (in seconds) Unity plays on Hover Entered.
Declaration
public float hapticHoverEnterDuration { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
hapticHoverEnterIntensity
The Haptics intensity Unity plays on Hover Entered.
Declaration
public float hapticHoverEnterIntensity { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
hapticHoverExitDuration
The Haptics duration (in seconds) Unity plays on Hover Exited.
Declaration
public float hapticHoverExitDuration { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
hapticHoverExitIntensity
The Haptics intensity Unity plays on Hover Exited.
Declaration
public float hapticHoverExitIntensity { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
hapticSelectCancelDuration
The Haptics duration (in seconds) Unity plays on Select Canceled.
Declaration
public float hapticSelectCancelDuration { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
hapticSelectCancelIntensity
The Haptics intensity Unity plays on Select Canceled.
Declaration
public float hapticSelectCancelIntensity { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
hapticSelectEnterDuration
The Haptics duration (in seconds) Unity plays on Select Entered.
Declaration
public float hapticSelectEnterDuration { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
hapticSelectEnterIntensity
The Haptics intensity Unity plays on Select Entered.
Declaration
public float hapticSelectEnterIntensity { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
hapticSelectExitDuration
The Haptics duration (in seconds) Unity plays on Select Exited.
Declaration
public float hapticSelectExitDuration { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
hapticSelectExitIntensity
The Haptics intensity Unity plays on Select Exited.
Declaration
public float hapticSelectExitIntensity { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
hideControllerOnSelect
Controls whether this Interactor should hide the controller model on selection.
Declaration
public bool hideControllerOnSelect { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
isSelectActive
(Read Only) Indicates whether this Interactor is in a state where it could select.
Declaration
public override bool isSelectActive { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
isUISelectActive
(Read Only) Whether or not Unity considers the UI Press controller input pressed.
Declaration
protected virtual bool isUISelectActive { get; }
Property Value
Type | Description |
---|---|
bool |
playAudioClipOnHoverCanceled
Controls whether Unity plays an AudioClip on Hover Canceled.
Declaration
public bool playAudioClipOnHoverCanceled { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
playAudioClipOnHoverEntered
Controls whether Unity plays an AudioClip on Hover Entered.
Declaration
public bool playAudioClipOnHoverEntered { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
playAudioClipOnHoverExited
Controls whether Unity plays an AudioClip on Hover Exited.
Declaration
public bool playAudioClipOnHoverExited { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
playAudioClipOnSelectCanceled
Controls whether Unity plays an AudioClip on Select Canceled.
Declaration
public bool playAudioClipOnSelectCanceled { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
playAudioClipOnSelectEntered
Controls whether Unity plays an AudioClip on Select Entered.
Declaration
public bool playAudioClipOnSelectEntered { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
playAudioClipOnSelectExited
Controls whether Unity plays an AudioClip on Select Exited.
Declaration
public bool playAudioClipOnSelectExited { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
playHapticsOnHoverCanceled
Controls whether Unity plays haptics on Hover Canceled.
Declaration
public bool playHapticsOnHoverCanceled { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
playHapticsOnHoverEntered
Controls whether Unity plays haptics on Hover Entered.
Declaration
public bool playHapticsOnHoverEntered { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
playHapticsOnHoverExited
Controls whether Unity plays haptics on Hover Exited.
Declaration
public bool playHapticsOnHoverExited { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
playHapticsOnSelectCanceled
Controls whether Unity plays haptics on Select Canceled.
Declaration
public bool playHapticsOnSelectCanceled { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
playHapticsOnSelectEntered
Controls whether Unity plays haptics on Select Entered.
Declaration
public bool playHapticsOnSelectEntered { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
playHapticsOnSelectExited
Controls whether Unity plays haptics on Select Exited.
Declaration
public bool playHapticsOnSelectExited { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
selectActionTrigger
Choose how Unity interprets the select input action from the controller. Controls between different input styles for determining if this Interactor can select, such as whether the button is currently pressed or just toggles the active state.
Declaration
public XRBaseControllerInteractor.InputTriggerType selectActionTrigger { get; set; }
Property Value
Type | Description |
---|---|
XRBaseControllerInteractor.InputTriggerType |
See Also
shouldActivate
(Read Only) Indicates whether this interactor is in a state where it should send the activate event this frame.
Declaration
public virtual bool shouldActivate { get; }
Property Value
Type | Description |
---|---|
bool |
shouldDeactivate
(Read Only) Indicates whether this interactor is in a state where it should send the deactivate event this frame.
Declaration
public virtual bool shouldDeactivate { get; }
Property Value
Type | Description |
---|---|
bool |
targetPriorityMode
Specifies how many Interactables should be monitored in the targetsForSelection property.
Declaration
public override TargetPriorityMode targetPriorityMode { get; set; }
Property Value
Type | Description |
---|---|
TargetPriorityMode |
Overrides
uiScrollValue
(Read Only) The current scroll value Unity would apply to the UI.
Declaration
protected Vector2 uiScrollValue { get; }
Property Value
Type | Description |
---|---|
Vector2 | Returns a Vector2 with scroll strength for each axis. |
xrController
The controller instance that is queried for input.
Declaration
public XRBaseController xrController { get; set; }
Property Value
Type | Description |
---|---|
XRBaseController |
Remarks
Setting this property will trigger the OnXRControllerChanged() method when set externally.
Methods
Awake()
See MonoBehaviour.
Declaration
protected override void Awake()
Overrides
GetActivateTargets(List<IXRActivateInteractable>)
Retrieve the list of Interactables that this Interactor could possibly activate or deactivate this frame.
Declaration
public virtual void GetActivateTargets(List<IXRActivateInteractable> targets)
Parameters
Type | Name | Description |
---|---|---|
List<IXRActivateInteractable> | targets | The results list to populate with Interactables that are valid for activate or deactivate. |
Remarks
When implementing this method, Unity expects you to clear targets
before adding to it.
OnHoverEntering(HoverEnterEventArgs)
The XRInteractionManager calls this method right before the Interactor first initiates hovering over an Interactable in a first pass.
Declaration
protected override void OnHoverEntering(HoverEnterEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
HoverEnterEventArgs | args | Event data containing the Interactable that is being hovered over. |
Overrides
Remarks
args
is only valid during this method call, do not hold a reference to it.
See Also
OnHoverExiting(HoverExitEventArgs)
The XRInteractionManager calls this method right before the Interactor ends hovering over an Interactable in a first pass.
Declaration
protected override void OnHoverExiting(HoverExitEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
HoverExitEventArgs | args | Event data containing the Interactable that is no longer hovered over. |
Overrides
Remarks
args
is only valid during this method call, do not hold a reference to it.
See Also
OnSelectEntering(SelectEnterEventArgs)
The XRInteractionManager calls this method right before the Interactor first initiates selection of an Interactable in a first pass.
Declaration
protected override void OnSelectEntering(SelectEnterEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
SelectEnterEventArgs | args | Event data containing the Interactable that is being selected. |
Overrides
Remarks
args
is only valid during this method call, do not hold a reference to it.
See Also
OnSelectExiting(SelectExitEventArgs)
The XRInteractionManager calls this method right before the Interactor ends selection of an Interactable in a first pass.
Declaration
protected override void OnSelectExiting(SelectExitEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
SelectExitEventArgs | args | Event data containing the Interactable that is no longer selected. |
Overrides
Remarks
args
is only valid during this method call, do not hold a reference to it.
See Also
PlayAudio(AudioClip)
Play an AudioClip.
Declaration
protected virtual void PlayAudio(AudioClip audioClip)
Parameters
Type | Name | Description |
---|---|---|
AudioClip | audioClip | The clip to play. |
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
public override void PreprocessInteractor(XRInteractionUpdateOrder.UpdatePhase updatePhase)
Parameters
Type | Name | Description |
---|---|---|
XRInteractionUpdateOrder.UpdatePhase | updatePhase | The update phase this is called during. |
Overrides
Remarks
Please see the XRInteractionManager and XRInteractionUpdateOrder.UpdatePhase documentation for more details on update order.
See Also
ProcessInteractor(UpdatePhase)
The XRInteractionManager or containing IXRInteractionGroup calls this method to update the Interactor after interaction events occur.
Declaration
public override void ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase updatePhase)
Parameters
Type | Name | Description |
---|---|---|
XRInteractionUpdateOrder.UpdatePhase | updatePhase | The update phase this is called during. |
Overrides
Remarks
Please see the XRInteractionManager and XRInteractionUpdateOrder.UpdatePhase documentation for more details on update order.
See Also
SendHapticImpulse(float, float)
Play a haptic impulse on the controller if one is available.
Declaration
public bool SendHapticImpulse(float amplitude, float duration)
Parameters
Type | Name | Description |
---|---|---|
float | amplitude | Amplitude (from 0.0 to 1.0) to play impulse at. |
float | duration | Duration (in seconds) to play haptic impulse. |
Returns
Type | Description |
---|---|
bool |