Struct ARRaycastHit
Represents the result of a raycast intersection with a trackable.
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
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 |
Properties
distance
The distance, in Unity world space, from the ray origin to the intersection point.
Declaration
public float distance { get; }
Property Value
| Type | Description |
|---|---|
| Single |
hitType
The type of trackable hit by the raycast.
Declaration
public TrackableType hitType { get; }
Property Value
| Type | Description |
|---|---|
| TrackableType |
pose
The Pose, in Unity world space, of the intersection point.
Declaration
public 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 float sessionRelativeDistance { get; }
Property Value
| Type | Description |
|---|---|
| Single |
sessionRelativePose
The Pose, in local (session) space, of the intersection point.
Declaration
public Pose sessionRelativePose { get; }
Property Value
| Type | Description |
|---|---|
| Pose |
trackableId
The session-unique identifier for the trackable that was hit.
Declaration
public 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 |
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 |
|
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 |
|