Class XRRayInteractor
Interactor used for interacting with interactables at a distance. This is handled via ray casts that update the current set of valid targets for this interactor.
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 Ray Interactor", 11)]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@3.0/api/UnityEngine.XR.Interaction.Toolkit.Interactors.XRRayInteractor.html")]
public class XRRayInteractor : XRBaseInputInteractor, IXRHoverInteractor, IXRSelectInteractor, IXRTargetPriorityInteractor, IXRGroupMember, IXRInteractionStrengthInteractor, IXRActivateInteractor, IXRInteractor, IAdvancedLineRenderable, ILineRenderable, IUIHoverInteractor, IUIInteractor, IXRRayProvider, IXRScaleValueProvider
Properties
acceleration
Gravity of the projectile in the reference frame.
Declaration
public float acceleration { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
additionalFlightTime
Additional flight time after the projectile lands at the adjusted ground level. Increasing this value will make the end point drop lower in height.
Declaration
public float additionalFlightTime { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
additionalGroundHeight
Additional height below ground level that the projectile will continue to. Increasing this value will make the end point drop lower in height.
Declaration
public float additionalGroundHeight { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
angle
The launch angle of the Projectile Curve. More specifically, this is the signed angle in degrees between the original attach forward direction and the plane of the reference frame, with positive angles when pointing upward.
Declaration
public float angle { get; }
Property Value
Type | Description |
---|---|
float |
autoDeselect
Whether this Interactor will automatically deselect an Interactable after selecting it via hover for a period of time.
Declaration
public bool autoDeselect { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
This only applies when an interactable is selected due to hoverToSelect.
See Also
blendVisualLinePoints
Blend the line sample points Unity uses for ray casting with the current pose of the controller. Use this to make the line visual stay connected with the controller instead of lagging behind.
Declaration
public bool blendVisualLinePoints { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
When the controller is configured to sample tracking input directly before rendering to reduce
input latency, the controller may be in a new position or rotation relative to the starting point
of the sample curve used for ray casting.
A value of false will make the line visual stay at a fixed reference frame rather than bending
or curving towards the end of the ray cast line.
blockUIOnInteractableSelection
Enabling this option will block UI interaction when selecting interactables.
Declaration
public bool blockUIOnInteractableSelection { get; set; }
Property Value
Type | Description |
---|---|
bool |
coneCastAngle
Gets or sets the angle in degrees of the cone used for cone casting. Will use regular ray casting if set to 0.
Declaration
public float coneCastAngle { get; set; }
Property Value
Type | Description |
---|---|
float |
controlPointDistance
Increase this value to make the peak of the curve further from the start point.
Declaration
public float controlPointDistance { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
controlPointHeight
Increase this value to make the peak of the curve higher relative to the start point.
Declaration
public float controlPointHeight { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
currentNearestValidTarget
The nearest IXRInteractable object hit by the ray that was inserted into the valid targets list when not selecting anything.
Declaration
protected IXRInteractable currentNearestValidTarget { get; }
Property Value
Type | Description |
---|---|
IXRInteractable |
Remarks
Updated during PreprocessInteractor(UpdatePhase).
directionalManipulationInput
Input to use for rotating the attach point to match the direction of the input. This effectively rotates the selected grab interactable or teleport target to match the direction of the input.
Declaration
public XRInputValueReader<Vector2> directionalManipulationInput { get; set; }
Property Value
Type | Description |
---|---|
XRInputValueReader<Vector2> |
Remarks
The direction angle should be computed as the arctangent function of x/y.
See Also
enableARRaycasting
Gets or sets whether this interactor is able to raycast against AR environment trackables.
Declaration
public bool enableARRaycasting { get; set; }
Property Value
Type | Description |
---|---|
bool |
enableUIInteraction
Enable to affect Unity UI GameObjects in a way that is similar to a mouse pointer. Requires the XR UI Input Module on the Event System.
Declaration
public bool enableUIInteraction { get; set; }
Property Value
Type | Description |
---|---|
bool |
endPointDistance
Increase this value distance to make the end of the curve further from the start point.
Declaration
public float endPointDistance { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
endPointHeight
Decrease this value to make the end of the curve drop lower relative to the start point.
Declaration
public float endPointHeight { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
hitClosestOnly
Whether Unity considers only the closest Interactable as a valid target for interaction.
Declaration
public bool hitClosestOnly { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
Enable this to make only the closest Interactable receive hover events. Otherwise, all hit Interactables will be considered valid and this Interactor will multi-hover.
See Also
hitDetectionType
Gets or sets which type of hit detection to use for the ray cast.
Declaration
public XRRayInteractor.HitDetectionType hitDetectionType { get; set; }
Property Value
Type | Description |
---|---|
XRRayInteractor.HitDetectionType |
hoverTimeToSelect
Number of seconds for which this Interactor must hover over an Interactable to select it if Hover To Select is enabled.
Declaration
public float hoverTimeToSelect { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
hoverToSelect
Whether this Interactor will automatically select an Interactable after hovering over it for a period of time.
Declaration
public bool hoverToSelect { get; set; }
Property Value
Type | Description |
---|---|
bool |
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
lineType
Gets or sets the type of ray cast.
Declaration
public XRRayInteractor.LineType lineType { get; set; }
Property Value
Type | Description |
---|---|
XRRayInteractor.LineType |
manipulateAttachTransform
Allows the user to move the Attach Transform using the thumbstick.
Declaration
public bool manipulateAttachTransform { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
maxRaycastDistance
Gets or sets the max distance of ray cast when the line type is a straight line. Increasing this value will make the line reach further.
Declaration
public float maxRaycastDistance { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
occludeARHitsWith2DObjects
Gets or sets whether AR raycast hits will be occluded by 2D world space objects such as UI.
Declaration
public bool occludeARHitsWith2DObjects { get; set; }
Property Value
Type | Description |
---|---|
bool |
occludeARHitsWith3DObjects
Gets or sets whether AR raycast hits will be occluded by 3D objects.
Declaration
public bool occludeARHitsWith3DObjects { get; set; }
Property Value
Type | Description |
---|---|
bool |
rayEndPoint
The last endpoint of this ray, either its maximum distance or a collision point.
Declaration
public Vector3 rayEndPoint { get; }
Property Value
Type | Description |
---|---|
Vector3 |
rayEndTransform
The Transform of the object this ray has collided with, if any.
Declaration
public Transform rayEndTransform { get; }
Property Value
Type | Description |
---|---|
Transform |
rayOriginTransform
The starting position and direction of any ray casts.
Declaration
public Transform rayOriginTransform { get; set; }
Property Value
Type | Description |
---|---|
Transform |
Remarks
Automatically instantiated and set in Awake() if null and initialized with the pose of the attachTransform. Setting this will not automatically destroy the previous object.
raycastMask
Gets or sets layer mask used for limiting ray cast targets.
Declaration
public LayerMask raycastMask { get; set; }
Property Value
Type | Description |
---|---|
LayerMask |
raycastSnapVolumeInteraction
Whether ray cast should include or ignore hits on trigger colliders that are snap volume colliders, even if the ray cast is set to ignore triggers. If you are not using gaze assistance or XR Interactable Snap Volume components, you should set this property to Ignore to avoid the performance cost.
Declaration
public XRRayInteractor.QuerySnapVolumeInteraction raycastSnapVolumeInteraction { get; set; }
Property Value
Type | Description |
---|---|
XRRayInteractor.QuerySnapVolumeInteraction |
Remarks
When set to Collide when raycastTriggerInteraction is set to ignore trigger colliders
(when set to Ignore or when set to UseGlobal
while queriesHitTriggers is false),
the ray cast query will be modified to include trigger colliders, but then this behavior will ignore any trigger collider
hits that are not snap volumes.
When set to Ignore when raycastTriggerInteraction is set to hit trigger colliders
(when set to Collide or when set to UseGlobal
while queriesHitTriggers is true),
this behavior will ignore any trigger collider hits that are snap volumes.
See Also
raycastTriggerInteraction
Gets or sets type of interaction with trigger colliders via ray cast.
Declaration
public QueryTriggerInteraction raycastTriggerInteraction { get; set; }
Property Value
Type | Description |
---|---|
QueryTriggerInteraction |
referenceFrame
The reference frame of the curve to define the ground plane and up. If not set at startup it will try to find the Unity.XR.CoreUtils.XROrigin.Origin GameObject, and if that does not exist it will use global up and origin by default.
Declaration
public Transform referenceFrame { get; set; }
Property Value
Type | Description |
---|---|
Transform |
See Also
rotateManipulationInput
Input to use for rotating the attach point over time. This effectively rotates the selected grab interactable while the input is pushed in either direction.
Declaration
public XRInputValueReader<Vector2> rotateManipulationInput { get; set; }
Property Value
Type | Description |
---|---|
XRInputValueReader<Vector2> |
Remarks
Uses the x-axis as the rotation input.
See Also
rotateMode
How the Attach Transform rotation manipulation is controlled.
Declaration
public XRRayInteractor.RotateMode rotateMode { get; set; }
Property Value
Type | Description |
---|---|
XRRayInteractor.RotateMode |
See Also
rotateReferenceFrame
The optional reference frame to define the up axis when rotating the Attach Transform. When not set, rotates about the local up axis of the Attach Transform.
Declaration
public Transform rotateReferenceFrame { get; set; }
Property Value
Type | Description |
---|---|
Transform |
See Also
rotateSpeed
Speed that the Attach Transform is rotated when rotateMode is set to RotateOverTime.
Declaration
public float rotateSpeed { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
sampleFrequency
The number of sample points Unity uses to approximate curved paths. Larger values produce a better quality approximate at the cost of reduced performance due to the number of ray casts.
Declaration
public int sampleFrequency { get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
A value of n will result in n - 1 line segments for ray cast. This property is not used when using StraightLine since the value would always be 2.
See Also
scaleDistanceDeltaInput
The input to use for providing a scale value to grab transformers for scaling based on a distance delta from last frame. This input is typically used for scaling with a pinch gesture on mobile AR.
Declaration
public XRInputValueReader<float> scaleDistanceDeltaInput { get; set; }
Property Value
Type | Description |
---|---|
XRInputValueReader<float> |
See Also
scaleMode
Property representing the scale mode that is supported by the implementation of the interface.
Declaration
public ScaleMode scaleMode { get; set; }
Property Value
Type | Description |
---|---|
ScaleMode |
See Also
scaleOverTimeInput
The input to use for providing a scale value to grab transformers for scaling over time. This effectively scales the selected grab interactable while the input is pushed in either direction.
Declaration
public XRInputValueReader<Vector2> scaleOverTimeInput { get; set; }
Property Value
Type | Description |
---|---|
XRInputValueReader<Vector2> |
Remarks
Uses the y-axis as the scale input.
See Also
scaleToggleInput
The input to use for toggling between Attach Transform manipulation modes to either scale or translate/rotate.
Declaration
public XRInputButtonReader scaleToggleInput { get; set; }
Property Value
Type | Description |
---|---|
XRInputButtonReader |
scaleValue
This is the current scale value for the specified scale mode. This value should be updated by the implementing class when other inputs are handled during the standard interaction processing loop.
Declaration
public float scaleValue { get; protected set; }
Property Value
Type | Description |
---|---|
float |
See Also
sphereCastRadius
Gets or sets radius used for sphere casting.
Declaration
public float sphereCastRadius { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
timeToAutoDeselect
Number of seconds for which this Interactor will keep an Interactable selected before automatically deselecting it.
Declaration
public float timeToAutoDeselect { get; set; }
Property Value
Type | Description |
---|---|
float |
Remarks
This only applies when an interactable is selected due to hoverToSelect.
See Also
trackableType
The ARTrackable types that will taken into consideration with the performed ARRaycast.
Declaration
public TrackableType trackableType { get; set; }
Property Value
Type | Description |
---|---|
TrackableType |
translateManipulationInput
Input to use for translating the attach point closer or further away from the interactor. This effectively moves the selected grab interactable along the ray.
Declaration
public XRInputValueReader<Vector2> translateManipulationInput { get; set; }
Property Value
Type | Description |
---|---|
XRInputValueReader<Vector2> |
Remarks
Uses the y-axis as the translation input.
translateSpeed
Speed that the Attach Transform is translated along the ray.
Declaration
public float translateSpeed { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
uiHoverEntered
The event that is called when the Interactor begins hovering over a UI element.
Declaration
public UIHoverEnterEvent uiHoverEntered { get; set; }
Property Value
Type | Description |
---|---|
UIHoverEnterEvent |
Remarks
The UIHoverEventArgs passed to each listener is only valid while the event is invoked, do not hold a reference to it.
uiHoverExited
The event that is called when this Interactor ends hovering over a UI element.
Declaration
public UIHoverExitEvent uiHoverExited { get; set; }
Property Value
Type | Description |
---|---|
UIHoverExitEvent |
Remarks
The UIHoverEventArgs passed to each listener is only valid while the event is invoked, do not hold a reference to it.
uiPressInput
Input to use for pressing UI elements. Functions like a mouse button when pointing over UI.
Declaration
public XRInputButtonReader uiPressInput { get; set; }
Property Value
Type | Description |
---|---|
XRInputButtonReader |
uiScrollInput
Input to use for scrolling UI elements. Functions like a mouse scroll wheel when pointing over UI.
Declaration
public XRInputValueReader<Vector2> uiScrollInput { get; set; }
Property Value
Type | Description |
---|---|
XRInputValueReader<Vector2> |
useForceGrab
Force grab moves the object to your hand rather than interacting with it at a distance.
Declaration
public bool useForceGrab { get; set; }
Property Value
Type | Description |
---|---|
bool |
velocity
Initial velocity of the projectile. Increasing this value will make the curve reach further.
Declaration
public float velocity { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
Methods
Awake()
See MonoBehaviour.
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 |
---|---|---|
IXRHoverInteractable | interactable | Interactable to check. |
Returns
Type | Description |
---|---|
bool | Returns true if the Interactable can be hovered over this frame. |
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 |
---|---|---|
IXRSelectInteractable | interactable | Interactable to check. |
Returns
Type | Description |
---|---|
bool | Returns true if the Interactable can be selected this frame. |
Overrides
See Also
GetHoverTimeToSelect(IXRInteractable)
Gets the number of seconds for which this interactor must hover over the interactable to select it if hoverToSelect is enabled.
Declaration
protected virtual float GetHoverTimeToSelect(IXRInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRInteractable | interactable | The interactable to get the duration for. |
Returns
Type | Description |
---|---|
float | Returns the number of seconds for which this Interactor must hover over an Interactable to select it. |
See Also
GetLineOriginAndDirection(out Vector3, out Vector3)
Gets the line origin and direction. Origin and Direction are in world space coordinates.
Declaration
public void GetLineOriginAndDirection(out Vector3 origin, out Vector3 direction)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | origin | Point in space where the line originates from. |
Vector3 | direction | Direction vector used to draw line. |
GetLinePoints(ref NativeArray<Vector3>, out int, Ray?)
Gets the polygonal chain represented by a list of endpoints which form line segments to approximate the curve. Positions are in world space coordinates.
Declaration
public bool GetLinePoints(ref NativeArray<Vector3> linePoints, out int numPoints, Ray? rayOriginOverride = null)
Parameters
Type | Name | Description |
---|---|---|
NativeArray<Vector3> | linePoints | When this method returns, contains the sample points if successful. |
int | numPoints | When this method returns, contains the number of sample points if successful. |
Ray? | rayOriginOverride | Optional ray origin override used when re-computing the line. |
Returns
Type | Description |
---|---|
bool | Returns true if the sample points form a valid line, such as by having at least two points. Otherwise, returns false. |
GetLinePoints(ref Vector3[], out int)
Gets the polygonal chain represented by a list of endpoints which form line segments to approximate the curve. Positions are in world space coordinates.
Declaration
public bool GetLinePoints(ref Vector3[] linePoints, out int numPoints)
Parameters
Type | Name | Description |
---|---|---|
Vector3[] | linePoints | When this method returns, contains the sample points if successful. |
int | numPoints | When this method returns, contains the number of sample points if successful. |
Returns
Type | Description |
---|---|
bool | Returns true if the sample points form a valid line, such as by having at least two points. Otherwise, returns false. |
Remarks
Getting line points with Vector3 array is much less performant than using a native array. Use GetLinePoints(ref NativeArray<Vector3>, out int, Ray?) instead if available.
GetTimeToAutoDeselect(IXRInteractable)
Gets the number of seconds for which this interactor will keep the interactable selected before automatically deselecting it.
Declaration
protected virtual float GetTimeToAutoDeselect(IXRInteractable interactable)
Parameters
Type | Name | Description |
---|---|---|
IXRInteractable | interactable | The interactable to get the duration for. |
Returns
Type | Description |
---|---|
float | Returns the number of seconds for which this Interactor will keep an Interactable selected before automatically deselecting it. |
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.
IsOverUIGameObject()
Use this to determine if the ray is currently hovering over a UI GameObject.
Declaration
public bool IsOverUIGameObject()
Returns
Type | Description |
---|---|
bool | Returns true if hovering over a UI element. Otherwise, returns false. |
Remarks
enableUIInteraction must be enabled, otherwise the function will always return false.
See Also
OnDisable()
See MonoBehaviour.
Declaration
protected override void OnDisable()
Overrides
OnDrawGizmosSelected()
See MonoBehaviour.
Declaration
protected virtual void OnDrawGizmosSelected()
OnEnable()
See MonoBehaviour.
Declaration
protected override void OnEnable()
Overrides
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
OnUIHoverEntered(UIHoverEventArgs)
The XRUIInputModule calls this method when the Interactor begins hovering over a UI element.
Declaration
protected virtual void OnUIHoverEntered(UIHoverEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
UIHoverEventArgs | args | Event data containing the UI element that is being hovered over. |
Remarks
args
is only valid during this method call, do not hold a reference to it.
See Also
OnUIHoverExited(UIHoverEventArgs)
The XRUIInputModule calls this method when the Interactor ends hovering over a UI element.
Declaration
protected virtual void OnUIHoverExited(UIHoverEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
UIHoverEventArgs | args | Event data containing the UI element that is no longer hovered over. |
Remarks
args
is only valid during this method call, do not hold a reference to it.
See Also
OnValidate()
See MonoBehaviour.
Declaration
protected void OnValidate()
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
RotateAttachTransform(Transform, float)
Rotates the Attach Transform for this interactor. This can be useful to rotate a held object.
Declaration
protected virtual void RotateAttachTransform(Transform attach, float directionAmount)
Parameters
Type | Name | Description |
---|---|---|
Transform | attach | The Attach Transform of the interactor. |
float | directionAmount | The rotation amount. |
RotateAttachTransform(Transform, Vector2, Quaternion)
Rotates the Attach Transform for this interactor to match a given direction. This can be useful to compute a direction angle for teleportation.
Declaration
protected virtual void RotateAttachTransform(Transform attach, Vector2 direction, Quaternion referenceRotation)
Parameters
Type | Name | Description |
---|---|---|
Transform | attach | The Attach Transform of the interactor. |
Vector2 | direction | The directional input. |
Quaternion | referenceRotation | The reference rotation to define the up axis for rotation. |
TranslateAttachTransform(Transform, Transform, float)
Translates the Attach Transform for this interactor. This can be useful to move a held object closer or further away from the interactor.
Declaration
protected virtual void TranslateAttachTransform(Transform rayOrigin, Transform attach, float directionAmount)
Parameters
Type | Name | Description |
---|---|---|
Transform | rayOrigin | The starting position and direction of any ray casts. |
Transform | attach | The Attach Transform of the interactor. |
float | directionAmount | The translation amount. |
TryGetCurrent3DRaycastHit(out RaycastHit)
Gets the first 3D ray cast hit, if any ray cast hits are available.
Declaration
public bool TryGetCurrent3DRaycastHit(out RaycastHit raycastHit)
Parameters
Type | Name | Description |
---|---|---|
RaycastHit | raycastHit | When this method returns, contains the ray cast hit if available; otherwise, the default value. |
Returns
Type | Description |
---|---|
bool | Returns true if a hit occurred, implying the ray cast hit information is valid. Otherwise, returns false. |
TryGetCurrent3DRaycastHit(out RaycastHit, out int)
Gets the first 3D ray cast hit, if any ray cast hits are available.
Declaration
public bool TryGetCurrent3DRaycastHit(out RaycastHit raycastHit, out int raycastEndpointIndex)
Parameters
Type | Name | Description |
---|---|---|
RaycastHit | raycastHit | When this method returns, contains the ray cast hit if available; otherwise, the default value. |
int | raycastEndpointIndex | When this method returns, contains the index of the sample endpoint if a hit occurred.
Otherwise, a value of |
Returns
Type | Description |
---|---|
bool | Returns true if a hit occurred, implying the ray cast hit information is valid. Otherwise, returns false. |
TryGetCurrentARRaycastHit(out ARRaycastHit)
Declaration
public bool TryGetCurrentARRaycastHit(out ARRaycastHit raycastHit)
Parameters
Type | Name | Description |
---|---|---|
ARRaycastHit | raycastHit |
Returns
Type | Description |
---|---|
bool |
TryGetCurrentARRaycastHit(out ARRaycastHit, out int)
Gets the first AR ray cast hit, if any ray cast hits are available.
Declaration
public bool TryGetCurrentARRaycastHit(out ARRaycastHit raycastHit, out int raycastEndpointIndex)
Parameters
Type | Name | Description |
---|---|---|
ARRaycastHit | raycastHit | When this method returns, contains the ray cast hit if available; otherwise, the default value. |
int | raycastEndpointIndex | When this method returns, contains the index of the sample endpoint if a hit occurred.
Otherwise, a value of |
Returns
Type | Description |
---|---|
bool | Returns true if a hit occurred, implying the ray cast hit information is valid. Otherwise, returns false. |
Remarks
If occludeARHitsWith2DObjects or occludeARHitsWith3DObjects are set to true and a
2D UI or 3D object are closer, the result will be false with the default values for both the raycastHit
and raycastEndpointIndex
.
TryGetCurrentRaycast(out RaycastHit?, out int, out RaycastResult?, out int, out bool)
Gets the first 3D and UI ray cast hits, if any ray cast hits are available.
Declaration
public bool TryGetCurrentRaycast(out RaycastHit? raycastHit, out int raycastHitIndex, out RaycastResult? uiRaycastHit, out int uiRaycastHitIndex, out bool isUIHitClosest)
Parameters
Type | Name | Description |
---|---|---|
RaycastHit? | raycastHit | When this method returns, contains the ray cast hit if available; otherwise, the default value. |
int | raycastHitIndex | When this method returns, contains the index of the sample endpoint if a hit occurred.
Otherwise, a value of |
RaycastResult? | uiRaycastHit | When this method returns, contains the UI ray cast result if available; otherwise, the default value. |
int | uiRaycastHitIndex | When this method returns, contains the index of the sample endpoint if a hit occurred.
Otherwise, a value of |
bool | isUIHitClosest | When this method returns, contains whether the UI ray cast result was the closest hit. |
Returns
Type | Description |
---|---|
bool | Returns true if either hit occurred, implying the ray cast hit information is valid. Otherwise, returns false. |
TryGetCurrentRaycast(out RaycastHit?, out int, out RaycastResult?, out int, out bool, out ARRaycastHit?, out int, out bool)
Gets the first 3D, AR and UI ray cast hits, if any ray cast hits are available.
Declaration
public bool TryGetCurrentRaycast(out RaycastHit? raycastHit, out int raycastHitIndex, out RaycastResult? uiRaycastHit, out int uiRaycastHitIndex, out bool isUIHitClosest, out ARRaycastHit? arRaycastHit, out int arRaycastHitIndex, out bool isARHitClosest)
Parameters
Type | Name | Description |
---|---|---|
RaycastHit? | raycastHit | When this method returns, contains the ray cast hit if available; otherwise, the default value. |
int | raycastHitIndex | When this method returns, contains the index of the sample endpoint if a hit occurred.
Otherwise, a value of |
RaycastResult? | uiRaycastHit | When this method returns, contains the UI ray cast result if available; otherwise, the default value. |
int | uiRaycastHitIndex | When this method returns, contains the index of the sample endpoint if a hit occurred.
Otherwise, a value of |
bool | isUIHitClosest | When this method returns, contains whether the UI ray cast result was the closest hit. |
ARRaycastHit? | arRaycastHit | When this method returns, contains the AR ray cast hit if available; otherwise, the default value. |
int | arRaycastHitIndex | When this method returns, contains the index of the sample endpoint if a hit occurred.
Otherwise, a value of |
bool | isARHitClosest | When this method returns, contains whether the AR ray cast result was the closest hit. |
Returns
Type | Description |
---|---|
bool | Returns true if either hit occurred, implying the ray cast hit information is valid. Otherwise, returns false. |
TryGetCurrentUIRaycastResult(out RaycastResult)
Gets the first UI ray cast result, if any ray cast results are available.
Declaration
public bool TryGetCurrentUIRaycastResult(out RaycastResult raycastResult)
Parameters
Type | Name | Description |
---|---|---|
RaycastResult | raycastResult | When this method returns, contains the UI ray cast result if available; otherwise, the default value. |
Returns
Type | Description |
---|---|
bool | Returns true if a hit occurred, implying the ray cast hit information is valid. Otherwise, returns false. |
TryGetCurrentUIRaycastResult(out RaycastResult, out int)
Gets the first UI ray cast result, if any ray cast results are available.
Declaration
public bool TryGetCurrentUIRaycastResult(out RaycastResult raycastResult, out int raycastEndpointIndex)
Parameters
Type | Name | Description |
---|---|---|
RaycastResult | raycastResult | When this method returns, contains the UI ray cast result if available; otherwise, the default value. |
int | raycastEndpointIndex | When this method returns, contains the index of the sample endpoint if a hit occurred.
Otherwise, a value of |
Returns
Type | Description |
---|---|
bool | Returns true if a hit occurred, implying the ray cast hit information is valid. Otherwise, returns false. |
TryGetHitInfo(out Vector3, out Vector3, out int, out bool)
Gets the current ray cast hit information, if a hit occurs. It returns the world position and the normal vector of the hit point, and its position in linePoints.
Declaration
public bool TryGetHitInfo(out Vector3 position, out Vector3 normal, out int positionInLine, out bool isValidTarget)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | When this method returns, contains the world position of the ray impact point if a hit occurred. |
Vector3 | normal | When this method returns, contains the world normal of the surface the ray hit if a hit occurred. |
int | positionInLine | When this method returns, contains the index of the sample endpoint within the list of points returned by GetLinePoints(ref Vector3[], out int)
where a hit occurred. Otherwise, a value of |
bool | isValidTarget | When this method returns, contains whether both a hit occurred and it is a valid target for interaction. |
Returns
Type | Description |
---|---|
bool | Returns true if a hit occurs, implying the ray cast hit information is valid. Otherwise, returns false. |
TryGetUIModel(out TrackedDeviceModel)
Attempts to retrieve the current UI Model.
Declaration
public bool TryGetUIModel(out TrackedDeviceModel model)
Parameters
Type | Name | Description |
---|---|---|
TrackedDeviceModel | model | The returned model that reflects the UI state of this Interactor. |
Returns
Type | Description |
---|---|
bool | Returns true if the model was able to retrieved. Otherwise, returns false. |
UpdateUIModel(ref TrackedDeviceModel)
Updates the current UI Model to match the state of the Interactor.
Declaration
public virtual void UpdateUIModel(ref TrackedDeviceModel model)
Parameters
Type | Name | Description |
---|---|---|
TrackedDeviceModel | model | The returned model that will match this Interactor. |