Class XRBaseInputInteractor
Abstract base class from which all interactors that use inputs to drive interaction state derive from.
Implements
Inherited Members
Namespace: UnityEngine.XR.Interaction.Toolkit.Interactors
Assembly: Unity.XR.Interaction.Toolkit.dll
Syntax
[MovedFrom("UnityEngine.XR.Interaction.Toolkit")]
public abstract class XRBaseInputInteractor : XRBaseInteractor, IXRHoverInteractor, IXRSelectInteractor, IXRTargetPriorityInteractor, IXRGroupMember, IXRInteractionStrengthInteractor, IXRActivateInteractor, IXRInteractor
Properties
activateInput
Input to use for activating an interactable. This can be used to trigger a secondary action on an interactable object, such as pulling a trigger on a ball launcher after picking it up.
Declaration
public XRInputButtonReader activateInput { get; set; }
Property Value
Type | Description |
---|---|
XRInputButtonReader |
allowActivate
Defines whether this interactor allows sending activate and deactivate events.
Declaration
public bool allowActivate { 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
buttonReaders
The list of button input readers used by this interactor. This interactor will automatically enable or disable direct actions if that mode is used during OnEnable() and OnDisable().
Declaration
protected List<XRInputButtonReader> buttonReaders { get; }
Property Value
Type | Description |
---|---|
List<XRInputButtonReader> |
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
logicalActivateState
The logical state of the activate input.
Declaration
public XRBaseInputInteractor.LogicalInputState logicalActivateState { get; }
Property Value
Type | Description |
---|---|
XRBaseInputInteractor.LogicalInputState |
See Also
logicalSelectState
The logical state of the select input.
Declaration
public XRBaseInputInteractor.LogicalInputState logicalSelectState { get; }
Property Value
Type | Description |
---|---|
XRBaseInputInteractor.LogicalInputState |
See Also
selectActionTrigger
Choose how Unity interprets the select input. Controls between different input styles for determining if this interactor can select, such as whether the button is currently held or whether the button toggles select upon being pressed.
Declaration
public XRBaseInputInteractor.InputTriggerType selectActionTrigger { get; set; }
Property Value
Type | Description |
---|---|
XRBaseInputInteractor.InputTriggerType |
See Also
selectInput
Input to use for selecting an interactable.
Declaration
public XRInputButtonReader selectInput { get; set; }
Property Value
Type | Description |
---|---|
XRInputButtonReader |
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
valueReaders
The list of value input readers used by this interactor. This interactor will automatically enable or disable direct actions if that mode is used during OnEnable() and OnDisable().
Declaration
protected List<XRInputValueReader> valueReaders { get; }
Property Value
Type | Description |
---|---|
List<XRInputValueReader> |
See Also
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.
OnDisable()
See MonoBehaviour.
Declaration
protected override void OnDisable()
Overrides
OnEnable()
See MonoBehaviour.
Declaration
protected override void OnEnable()
Overrides
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 |
See Also
SetInputProperty(ref XRInputButtonReader, XRInputButtonReader)
Helper method for setting an input property.
Declaration
protected void SetInputProperty(ref XRInputButtonReader property, XRInputButtonReader value)
Parameters
Type | Name | Description |
---|---|---|
XRInputButtonReader | property | The ref to the field. |
XRInputButtonReader | value | The new value being set. |
Remarks
If the application is playing, this method will also enable or disable directly embedded input actions serialized by the input if that mode is used. It will also add or remove the input from the list of button inputs to automatically manage enabling and disabling direct actions with this behavior.
See Also
SetInputProperty<TValue>(ref XRInputValueReader<TValue>, XRInputValueReader<TValue>)
Helper method for setting an input property.
Declaration
protected void SetInputProperty<TValue>(ref XRInputValueReader<TValue> property, XRInputValueReader<TValue> value) where TValue : struct
Parameters
Type | Name | Description |
---|---|---|
XRInputValueReader<TValue> | property | The ref to the field. |
XRInputValueReader<TValue> | value | The new value being set. |
Type Parameters
Name | Description |
---|---|
TValue | Type of the value read by the property, such as Vector2 or float. |
Remarks
If the application is playing, this method will also enable or disable directly embedded input actions serialized by the input if that mode is used. It will also add or remove the input from the list of value inputs to automatically manage enabling and disabling direct actions with this behavior.