Struct ARRaycastHit
Represents the result of a raycast intersection with a trackable.
Inherited Members
Namespace: UnityEngine.XR.ARFoundation
Assembly: Unity.XR.ARFoundation.dll
Syntax
public struct ARRaycastHit : IEquatable<ARRaycastHit>, IComparable<ARRaycastHit>
Constructors
ARRaycastHit(XRRaycastHit, float, 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. |
float | distance | The distance, in Unity world space, of the hit. |
Transform | transform | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ARRaycastHit(XRRaycastHit, float, 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. |
float | 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 |
---|---|
float |
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 |
---|---|
float |
sessionRelativePose
The Pose
, in local (session) space, of the intersection point.
Declaration
public 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 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 |
---|---|
int | 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 |
---|---|
bool |
|
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 |
---|---|
bool |
|
GetHashCode()
Generates a hash suitable for use with containers like HashSet
and Dictionary
.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code generated from this object's fields. |
Overrides
Operators
operator ==(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 |
---|---|
bool |
|
operator !=(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 |
---|---|
bool |
|