Interface IXRInteractable
An interface that represents an Interactable component that controls how a GameObject interacts with an Interactor component. An example is a Grab Interactable which can be picked up and moved by an Interactor.
Namespace: UnityEngine .XR.Interaction.Toolkit.Interactables
Assembly: Unity.XR.Interaction.Toolkit.dll
Syntax
[MovedFrom("UnityEngine.XR.Interaction.Toolkit")]
public interface IXRInteractable
Remarks
When scripting, you can typically write custom behaviors that derive from XRBase
Properties
colliders
(Read Only) Colliders to use for interaction with this Interactable.
Declaration
List<Collider> colliders { get; }
Property Value
See Also
interactionLayers
(Read Only) Allows interaction with Interactors whose Interaction Layer Mask overlaps with any Layer in this Interaction Layer Mask.
Declaration
InteractionLayerMask interactionLayers { get; }
Property Value
Type | Description |
---|---|
Interaction |
See Also
transform
(Read Only) The Transform associated with the Interactable.
Declaration
Transform transform { get; }
Property Value
Type | Description |
---|---|
Transform |
Remarks
When this Interactable is a component, this property is the Transform of the GameObject the component is attached to.
See Also
Methods
GetAttachTransform(IXRInteractor)
Gets the Transform that serves as the attachment point for a given Interactor.
Declaration
Transform GetAttachTransform(IXRInteractor interactor)
Parameters
Type | Name | Description |
---|---|---|
IXRInteractor | interactor | The specific Interactor 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
GetDistanceSqrToInteractor(IXRInteractor)
Calculates squared distance to an Interactor (based on colliders).
Declaration
float GetDistanceSqrToInteractor(IXRInteractor interactor)
Parameters
Type | Name | Description |
---|---|---|
IXRInteractor | interactor | Interactor to calculate distance against. |
Returns
Type | Description |
---|---|
float | Returns the minimum squared distance between the Interactor and this Interactable's colliders. |
See Also
OnRegistered(InteractableRegisteredEventArgs)
The XRInteraction
Declaration
void OnRegistered(InteractableRegisteredEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Interactable |
args | Event data containing the Interaction Manager that registered this Interactable. |
Remarks
args
is only valid during this method call, do not hold a reference to it.
See Also
OnUnregistered(InteractableUnregisteredEventArgs)
The XRInteraction
Declaration
void OnUnregistered(InteractableUnregisteredEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Interactable |
args | Event data containing the Interaction Manager that unregistered this Interactable. |
Remarks
args
is only valid during this method call, do not hold a reference to it.
See Also
ProcessInteractable(UpdatePhase)
The XRInteraction
Declaration
void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
Parameters
Type | Name | Description |
---|---|---|
XRInteraction |
updatePhase | The update phase this is called during. |
Remarks
Please see the XRInteraction
See Also
Events
registered
Calls the methods in its invocation list when this Interactable is registered with an XRInteraction
Declaration
event Action<InteractableRegisteredEventArgs> registered
Event Type
Type | Description |
---|---|
Action<Interactable |
Remarks
The Interactable
See Also
unregistered
Calls the methods in its invocation list when this Interactable is unregistered from an XRInteraction
Declaration
event Action<InteractableUnregisteredEventArgs> unregistered
Event Type
Type | Description |
---|---|
Action<Interactable |
Remarks
The Interactable