Class XRGrabInteractable
Interactable component that allows basic "grab" functionality. Can attach to selecting interactor and follow it around while obeying physics (and inherit velocity when released).
Inherited Members
Namespace: UnityEngine.XR.Interaction.Toolkit
Syntax
[SelectionBase]
[DisallowMultipleComponent]
[RequireComponent(typeof(Rigidbody))]
[AddComponentMenu("XR/XR Grab Interactable")]
public class XRGrabInteractable : XRBaseInteractable
Properties
attachEaseInTime
Time it takes to ease in the attach (a value of 0 indicates no easing).
Declaration
public float attachEaseInTime { get; set; }
Property Value
Type | Description |
---|---|
Single |
attachTransform
The attachment point to use on this Interactable (will use transform.position as center if none set).
Declaration
public Transform attachTransform { get; set; }
Property Value
Type | Description |
---|---|
Transform |
gravityOnDetach
Whether object has gravity when released.
Declaration
public bool gravityOnDetach { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
movementType
The movement type for the Rigidbody.
Declaration
public XRBaseInteractable.MovementType movementType { get; set; }
Property Value
Type | Description |
---|---|
XRBaseInteractable.MovementType |
See Also
retainTransformParent
Whether to retain the transform's location in the scene hierarchy when the object is dropped.
Declaration
public bool retainTransformParent { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
selectingInteractor
(Read Only) The current selecting interactor for this interactable.
Declaration
public XRBaseInteractor selectingInteractor { get; }
Property Value
Type | Description |
---|---|
XRBaseInteractor |
smoothPosition
Whether smoothing is applied to the position of the object.
Declaration
public bool smoothPosition { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
See Also
smoothPositionAmount
The smoothing applied to the object's position when following.
Declaration
public float smoothPositionAmount { get; set; }
Property Value
Type | Description |
---|---|
Single |
See Also
smoothRotation
Apply smoothing to the follow rotation of the object.
Declaration
public bool smoothRotation { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
See Also
smoothRotationAmount
The smoothing applied to the object's rotation when following.
Declaration
public float smoothRotationAmount { get; set; }
Property Value
Type | Description |
---|---|
Single |
See Also
throwAngularVelocityScale
The angular velocity scale used when throwing.
Declaration
public float throwAngularVelocityScale { get; set; }
Property Value
Type | Description |
---|---|
Single |
throwOnDetach
Whether the object inherits the interactor's velocity when released.
Declaration
public bool throwOnDetach { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
throwSmoothingCurve
The curve to use to weight velocity smoothing (most recent frames to the right).
Declaration
public AnimationCurve throwSmoothingCurve { get; set; }
Property Value
Type | Description |
---|---|
AnimationCurve |
throwSmoothingDuration
The time period to average thrown velocity over.
Declaration
public float throwSmoothingDuration { get; set; }
Property Value
Type | Description |
---|---|
Single |
throwVelocityScale
The velocity scale used when throwing.
Declaration
public float throwVelocityScale { get; set; }
Property Value
Type | Description |
---|---|
Single |
tightenPosition
The maximum follow position difference when using smoothing.
Declaration
public float tightenPosition { get; set; }
Property Value
Type | Description |
---|---|
Single |
See Also
tightenRotation
The maximum follow rotation difference when using smoothing.
Declaration
public float tightenRotation { get; set; }
Property Value
Type | Description |
---|---|
Single |
See Also
trackPosition
Whether this interactable should track the position of the interactor.
Declaration
public bool trackPosition { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
trackRotation
Whether this interactable should track the rotation of the interactor.
Declaration
public bool trackRotation { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
Awake()
Declaration
protected override void Awake()
Overrides
Drop()
Declaration
protected void Drop()
IsHoverableBy(XRBaseInteractor)
Determines if this interactable can be hovered by a given interactor.
Declaration
public override bool IsHoverableBy(XRBaseInteractor interactor)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractor | interactor | Interactor to check for a valid hover state with. |
Returns
Type | Description |
---|---|
Boolean | Returns true if hovering is valid this frame. Returns false if not. |
Overrides
OnSelectCanceling(XRBaseInteractor)
This method is called by the interaction manager right before the interactor targeting this interactable is disabled or destroyed, or if the interactable is unregistered.
Declaration
protected override void OnSelectCanceling(XRBaseInteractor interactor)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractor | interactor | Interactor that is ending the selection. |
Overrides
See Also
OnSelectEntered(XRBaseInteractor)
This method is called by the interaction manager when the interactor first initiates selection of an interactable.
Declaration
protected override void OnSelectEntered(XRBaseInteractor interactor)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractor | interactor | Interactor that is initiating the selection. |
Overrides
See Also
OnSelectEntering(XRBaseInteractor)
This method is called by the interaction manager right before the interactor first initiates selection of an interactable.
Declaration
protected override void OnSelectEntering(XRBaseInteractor interactor)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractor | interactor | Interactor that is initiating the selection. |
Overrides
See Also
OnSelectExiting(XRBaseInteractor)
This method is called by the interaction manager right before the interactor ends selection of an interactable.
Declaration
protected override void OnSelectExiting(XRBaseInteractor interactor)
Parameters
Type | Name | Description |
---|---|---|
XRBaseInteractor | interactor | Interactor that is ending the selection. |
Overrides
See Also
ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase)
This method is called by the interaction manager to update the interactable. Please see the interaction manager documentation for more details on update order.
Declaration
public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
Parameters
Type | Name | Description |
---|---|---|
XRInteractionUpdateOrder.UpdatePhase | updatePhase |