Struct ARRaycastHit
Represents the result of a raycast intersection with a trackable.
Inherited Members
Namespace: UnityEngine.XR.ARFoundation
Syntax
public struct ARRaycastHit : IEquatable<ARRaycastHit>, IComparable<ARRaycastHit>
Constructors
ARRaycastHit(XRRaycastHit, Single, Transform)
Constructor invoked by Raycast(Vector2, List<ARRaycastHit>, TrackableType) and Raycast(Ray, List<ARRaycastHit>, TrackableType).
Declaration
[Obsolete("Use ARRaycastHit(XRRaycastHit, float, Transform, ARTrackable) instead. (2020-10-09)")]
public ARRaycastHit(XRRaycastHit hit, float distance, Transform transform)
Parameters
Type | Name | Description |
---|---|---|
XRRaycastHit | hit | Session-relative raycast hit data. |
Single | distance | The distance, in Unity world space, of the hit. |
Transform | transform | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ARRaycastHit(XRRaycastHit, Single, Transform, ARTrackable)
Constructor invoked by Raycast(Vector2, List<ARRaycastHit>, TrackableType) and Raycast(Ray, List<ARRaycastHit>, TrackableType).
Declaration
public ARRaycastHit(XRRaycastHit hit, float distance, Transform transform, ARTrackable trackable)
Parameters
Type | Name | Description |
---|---|---|
XRRaycastHit | hit | Session-relative raycast hit data. |
Single | distance | The distance, in Unity world space, of the hit. |
Transform | transform | The |
ARTrackable | trackable | The trackable that was hit by this raycast, or |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
Properties
distance
The distance, in Unity world space, from the ray origin to the intersection point.
Declaration
public readonly float distance { get; }
Property Value
Type | Description |
---|---|
Single |
hitType
The type of trackable hit by the raycast.
Declaration
public readonly TrackableType hitType { get; }
Property Value
Type | Description |
---|---|
TrackableType |
pose
The Pose
, in Unity world space, of the intersection point.
Declaration
public readonly Pose pose { get; }
Property Value
Type | Description |
---|---|
Pose |
sessionRelativeDistance
The distance, in local (session) space, from the ray origin to the intersection point.
Declaration
public readonly float sessionRelativeDistance { get; }
Property Value
Type | Description |
---|---|
Single |
sessionRelativePose
The Pose
, in local (session) space, of the intersection point.
Declaration
public readonly Pose sessionRelativePose { get; }
Property Value
Type | Description |
---|---|
Pose |
trackable
The ARTrackable that this raycast hit, or null
if no ARTrackable was hit.
See hitType to determine what type of trackable, if any, was hit.
Declaration
public readonly ARTrackable trackable { get; }
Property Value
Type | Description |
---|---|
ARTrackable |
trackableId
The session-unique identifier for the trackable that was hit.
Declaration
public readonly TrackableId trackableId { get; }
Property Value
Type | Description |
---|---|
TrackableId |
Methods
CompareTo(ARRaycastHit)
Used for sorting two raycast hits by distance. Uses CompareTo on the raycasts' distance properties.
Declaration
public int CompareTo(ARRaycastHit other)
Parameters
Type | Name | Description |
---|---|---|
ARRaycastHit | other | The other ARRaycastHit to compare against. |
Returns
Type | Description |
---|---|
Int32 | A value less than zero if this raycast hit is closer than |
Implements
Equals(Object)
Tests for equality.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The |
Returns
Type | Description |
---|---|
Boolean |
|
Overrides
Equals(ARRaycastHit)
Tests for equality.
Declaration
public bool Equals(ARRaycastHit other)
Parameters
Type | Name | Description |
---|---|---|
ARRaycastHit | other | The other ARRaycastHit to compare against. |
Returns
Type | Description |
---|---|
Boolean |
|
Implements
GetHashCode()
Generates a hash suitable for use with containers like HashSet
and Dictionary
.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A hash code generated from this object's fields. |
Overrides
Operators
Equality(ARRaycastHit, ARRaycastHit)
Tests for equality. Same as Equals(ARRaycastHit).
Declaration
public static bool operator ==(ARRaycastHit lhs, ARRaycastHit rhs)
Parameters
Type | Name | Description |
---|---|---|
ARRaycastHit | lhs | The left-hand side of the comparison. |
ARRaycastHit | rhs | The right-hand side of the comparison. |
Returns
Type | Description |
---|---|
Boolean |
|
Inequality(ARRaycastHit, ARRaycastHit)
Tests for inequality. Same as !
Equals(ARRaycastHit).
Declaration
public static bool operator !=(ARRaycastHit lhs, ARRaycastHit rhs)
Parameters
Type | Name | Description |
---|---|---|
ARRaycastHit | lhs | The left-hand side of the comparison. |
ARRaycastHit | rhs | The right-hand side of the comparison. |
Returns
Type | Description |
---|---|
Boolean |
|