Class XRDirectInteractor
Interactor used for directly interacting with interactables that are touching. This is handled via trigger volumes that update the current set of valid targets for this interactor. This component must have a collision volume that is set to be a trigger to work.
Inheritance
Implements
Inherited Members
Namespace: UnityEngine .XR.Interaction.Toolkit.Interactors
Assembly: Unity.XR.Interaction.Toolkit.dll
Syntax
[MovedFrom("UnityEngine.XR.Interaction.Toolkit")]
[DisallowMultipleComponent]
[AddComponentMenu("XR/Interactors/XR Direct Interactor", 11)]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@3.1/api/UnityEngine.XR.Interaction.Toolkit.Interactors.XRDirectInteractor.html")]
public class XRDirectInteractor : XRBaseInputInteractor, IXRHoverInteractor, IXRSelectInteractor, IXRTargetPriorityInteractor, IXRGroupMember, IXRInteractionStrengthInteractor, IXRActivateInteractor, IXRInteractor
Properties
improveAccuracyWithSphereCollider
When a Sphere Collider component is the only collider on this interactor, and no Rigidbody component is attached, the interactor will use Burst compiler optimizations and sphere casts instead of relying on physics trigger events to evaluate direct interactions when this property is enabled. This also improves inter-frame accuracy and reliability.
Declaration
public bool improveAccuracyWithSphereCollider { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
Cannot change this value at runtime after Awake
.
Enabling this property can improve inter-frame reliability during fast motion when the requirements for optimization are met
by running on each Update instead of Fixed Update and using a sphere cast to determine valid targets.
Disable to force the use of trigger events, such as the OnTriggerStay
and FixedUpdate
methods.
See Also
physicsLayerMask
Physics layer mask used for limiting direct interactor overlaps when using the improve
Declaration
public LayerMask physicsLayerMask { get; set; }
Property Value
Type | Description |
---|---|
Layer |
physicsTriggerInteraction
Determines whether the direct interactor sphere overlap will hit triggers when using the improve
Declaration
public QueryTriggerInteraction physicsTriggerInteraction { get; set; }
Property Value
Type | Description |
---|---|
Query |
Remarks
When set to Use
unsortedValidTargets
The set of Interactables that this Interactor could possibly interact with this frame. This list is not sorted by priority.
Declaration
protected List<IXRInteractable> unsortedValidTargets { get; }
Property Value
Type | Description |
---|---|
List<IXRInteractable> |
See Also
usingSphereColliderAccuracyImprovement
Whether the requirements were successfully met to use the alternate improved collider accuracy code path.
Declaration
public bool usingSphereColliderAccuracyImprovement { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
The requirements are a single Sphere Collider component and no Rigidbody component on this GameObject.
See Also
Methods
Awake()
See Mono
Declaration
protected override void Awake()
Overrides
CanHover(IXRHoverInteractable)
Determines if the Interactable is valid for hover this frame.
Declaration
public override bool CanHover(IXRHoverInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRHover |
interactable | Interactable to check. |
Returns
Overrides
See Also
CanSelect(IXRSelectInteractable)
Determines if the Interactable is valid for selection this frame.
Declaration
public override bool CanSelect(IXRSelectInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRSelect |
interactable | Interactable to check. |
Returns
Overrides
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 override 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. |
Overrides
Remarks
When implementing this method, Unity expects you to clear targets
before adding to it.
OnDisable()
See Mono
Declaration
protected override void OnDisable()
Overrides
OnEnable()
See Mono
Declaration
protected override void OnEnable()
Overrides
OnRegistered(InteractorRegisteredEventArgs)
The XRInteraction
Declaration
protected override void OnRegistered(InteractorRegisteredEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Interactor |
args | Event data containing the Interaction Manager that registered this Interactor. |
Overrides
Remarks
args
is only valid during this method call, do not hold a reference to it.
See Also
OnTriggerEnter(Collider)
See Mono
Declaration
protected void OnTriggerEnter(Collider other)
Parameters
OnTriggerExit(Collider)
See Mono
Declaration
protected void OnTriggerExit(Collider other)
Parameters
OnTriggerStay(Collider)
See Mono
Declaration
protected void OnTriggerStay(Collider other)
Parameters
OnUnregistered(InteractorUnregisteredEventArgs)
The XRInteraction
Declaration
protected override void OnUnregistered(InteractorUnregisteredEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Interactor |
args | Event data containing the Interaction Manager that unregistered this Interactor. |
Overrides
Remarks
args
is only valid during this method call, do not hold a reference to it.
See Also
PreprocessInteractor(UpdatePhase)
The XRInteraction
Declaration
public override void PreprocessInteractor(XRInteractionUpdateOrder.UpdatePhase updatePhase)
Parameters
Type | Name | Description |
---|---|---|
XRInteraction |
updatePhase | The update phase this is called during. |
Overrides
Remarks
Please see the XRInteraction
See Also
ProcessInteractor(UpdatePhase)
The XRInteraction
Declaration
public override void ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase updatePhase)
Parameters
Type | Name | Description |
---|---|---|
XRInteraction |
updatePhase | The update phase this is called during. |
Overrides
Remarks
Please see the XRInteraction