Interface IXRInteractor
An interface that represents an Interactor component that controls how a GameObject interacts with an Interactable component. An example is a Ray Interactor which uses ray casting to find valid Interactable objects to manipulate.
Namespace: UnityEngine.XR.Interaction.Toolkit
Syntax
public interface IXRInteractor
Remarks
When scripting, you can typically write custom behaviors that derive from XRBaseInteractor or one of its derived classes rather than implementing this interface directly.
Properties
interactionLayers
(Read Only) Allows interaction with Interactables whose Interaction Layer Mask overlaps with any Layer in this Interaction Layer Mask.
Declaration
InteractionLayerMask interactionLayers { get; }
Property Value
Type | Description |
---|---|
InteractionLayerMask |
See Also
transform
(Read Only) The Transform associated with the Interactor.
Declaration
Transform transform { get; }
Property Value
Type | Description |
---|---|
Transform |
Remarks
When this Interactor is a component, this property is the Transform of the GameObject the component is attached to.
Methods
GetAttachTransform(IXRInteractable)
Gets the Transform that is used as the attachment point for a given Interactable.
Declaration
Transform GetAttachTransform(IXRInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRInteractable | interactable | The specific Interactable as context to get the attachment point for. |
Returns
Type | Description |
---|---|
Transform | Returns the attachment point Transform. |
Remarks
This should typically return the Transform of a child GameObject or the transform itself.
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
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.
OnRegistered(InteractorRegisteredEventArgs)
The XRInteractionManager calls this method when this Interactor is registered with it.
Declaration
void OnRegistered(InteractorRegisteredEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
InteractorRegisteredEventArgs | 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
OnUnregistered(InteractorUnregisteredEventArgs)
The XRInteractionManager calls this method when this Interactor is unregistered from it.
Declaration
void OnUnregistered(InteractorUnregisteredEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
InteractorUnregisteredEventArgs | 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(XRInteractionUpdateOrder.UpdatePhase)
The XRInteractionManager 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
void PreprocessInteractor(XRInteractionUpdateOrder.UpdatePhase updatePhase)
Parameters
Type | Name | Description |
---|---|---|
XRInteractionUpdateOrder.UpdatePhase | updatePhase | The update phase this is called during. |
Remarks
Please see the XRInteractionManager and XRInteractionUpdateOrder.UpdatePhase documentation for more details on update order.
See Also
ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase)
The XRInteractionManager calls this method to update the Interactor after interaction events occur.
Declaration
void ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase updatePhase)
Parameters
Type | Name | Description |
---|---|---|
XRInteractionUpdateOrder.UpdatePhase | updatePhase | The update phase this is called during. |
Remarks
Please see the XRInteractionManager and XRInteractionUpdateOrder.UpdatePhase documentation for more details on update order.
See Also
Events
registered
Calls the methods in its invocation list when this Interactor is registered with an Interaction Manager.
Declaration
event Action<InteractorRegisteredEventArgs> registered
Event Type
Type | Description |
---|---|
Action<InteractorRegisteredEventArgs> |
Remarks
The InteractorRegisteredEventArgs passed to each listener is only valid while the event is invoked, do not hold a reference to it.
See Also
unregistered
Calls the methods in its invocation list when this Interactor is unregistered from an Interaction Manager.
Declaration
event Action<InteractorUnregisteredEventArgs> unregistered
Event Type
Type | Description |
---|---|
Action<InteractorUnregisteredEventArgs> |
Remarks
The InteractorUnregisteredEventArgs passed to each listener is only valid while the event is invoked, do not hold a reference to it.