docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct ARRaycastHit

    Represents the result of a raycast intersection with a trackable.

    Implements
    IEquatable<ARRaycastHit>
    IComparable<ARRaycastHit>
    Inherited Members
    ValueType.ToString()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    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 Transform that transforms from session space to world space.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if transform is null.

    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 Transform that transforms from session space to world space.

    ARTrackable trackable

    The trackable that was hit by this raycast, or null if no trackable was hit.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if transform is null.

    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 other, zero if the distances are equal, and a positive value if other is closer.

    Equals(object)

    Tests for equality.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj

    The object to compare against.

    Returns
    Type Description
    bool

    True if obj is of type ARRaycastHit and Equals(ARRaycastHit) also returns true; otherwise false.

    Overrides
    ValueType.Equals(object)

    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

    True if every field in other is equal to this ARRaycastHit, otherwise false.

    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
    ValueType.GetHashCode()

    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

    True if lhs is equal to rhs, otherwise false.

    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

    True if lhs is not equal to rhs, otherwise false.

    Implements

    IEquatable<T>
    IComparable<T>
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)