docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct RaycastQuery

    Represents a raycast query.

    Implements
    IEquatable<RaycastQuery>
    Inherited Members
    ValueType.ToString()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.XR.MagicLeap
    Assembly: UnityEngine.XR.MagicLeap.dll
    Syntax
    public struct RaycastQuery : IEquatable<RaycastQuery>

    Constructors

    RaycastQuery(Ray, bool)

    Constructs a "single-point" raycast query, i.e., width and height are both 1.

    Declaration
    public RaycastQuery(Ray ray, bool collideWithUnobserved = false)
    Parameters
    Type Name Description
    Ray ray

    The ray, in session space, to cast.

    bool collideWithUnobserved

    If true, a ray will temrinate when encountering an unobserved area and return a surface or the ray will continue until it ends or hits an observed surface.

    RaycastQuery(Ray, Vector3, int, int, float, bool)

    Constructs a raycast query.

    Declaration
    public RaycastQuery(Ray ray, Vector3 up, int width, int height, float horizontalFov, bool collideWithUnobserved)
    Parameters
    Type Name Description
    Ray ray

    The ray, in session space, to cast.

    Vector3 up

    If multiple rays are to be fired (i.e., width or height are greater than 1), this is used to determine the coordinate system used to calculate the directions of those rays; therefore must be orthogonal to the direction vector. This parameter is has no effect on a single-point raycast.

    int width

    The number of horizontal rays to cast. Must be at least 1.

    int height

    The number of vertical rays to cast. Must be at least 1.

    float horizontalFov

    The horizontal field of view, in degrees. When width or height are greater than 1, this is used to determine the frustum in which to cast multiple rays.

    bool collideWithUnobserved

    If true, a ray will temrinate when encountering an unobserved area and return a surface or the ray will continue until it ends or hits an observed surface.

    Remarks

    If width or height are greater than 1, width * height rays are cast from the ray origin within a frustum defined by horizontalFov and up.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Thrown if width is less than 1.

    ArgumentOutOfRangeException

    Thrown if height is less than 1.

    ArgumentException

    Thrown if width or height is greater than 1 but up is not orthogonal to the ray's direction.

    ArgumentException

    Thrown if width or height is greater than 1, but up is zero.

    Properties

    collideWithUnobserved

    If true, a ray will temrinate when encountering an unobserved area and return a surface or the ray will continue until it ends or hits an observed surface.

    Declaration
    public readonly bool collideWithUnobserved { get; }
    Property Value
    Type Description
    bool

    height

    The number of vertical rays to cast.

    Declaration
    public readonly int height { get; }
    Property Value
    Type Description
    int

    horizontalFov

    The horizontal field of view, in degrees. When width or height are greater than 1, this is used to determine the frustum in which to cast multiple rays.

    Declaration
    public readonly float horizontalFov { get; }
    Property Value
    Type Description
    float

    ray

    A Ray, in session space.

    Declaration
    public readonly Ray ray { get; }
    Property Value
    Type Description
    Ray

    up

    If multiple rays are to be fired (i.e., width or height are greater than 1), this is used to determine the coordinate system used to calculate the directions of those rays; therefore must be orthogonal to the direction vector. This parameter is has no effect on a single-point raycast.

    Declaration
    public readonly Vector3 up { get; }
    Property Value
    Type Description
    Vector3

    width

    The number of horizontal rays to cast.

    Declaration
    public readonly int width { get; }
    Property Value
    Type Description
    int

    Methods

    Equals(object)

    IEquatable interface. Compares for equality.

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

    The object to compare for equality.

    Returns
    Type Description
    bool

    true if obj is of type RaycastQuery and compares equal with Equals(RaycastQuery).

    Overrides
    ValueType.Equals(object)

    Equals(RaycastQuery)

    IEquatable interface. Comapres for equality.

    Declaration
    public bool Equals(RaycastQuery other)
    Parameters
    Type Name Description
    RaycastQuery other

    The RaycastQuery to compare against.

    Returns
    Type Description
    bool

    true if all fields of this RaycastQuery compare equal to other.

    GetHashCode()

    Computes a hash code suitable for use in a Dictionary or HashSet.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A hash code suitable for use in a Dictionary or HashSet.

    Overrides
    ValueType.GetHashCode()

    Operators

    operator ==(RaycastQuery, RaycastQuery)

    Comapres for equality. Same as Equals(RaycastQuery).

    Declaration
    public static bool operator ==(RaycastQuery lhs, RaycastQuery rhs)
    Parameters
    Type Name Description
    RaycastQuery lhs

    The left-hand side of the comparison.

    RaycastQuery rhs

    The right-hand side of the comparison.

    Returns
    Type Description
    bool

    true if all fields of this RaycastQuery compare equal to other.

    operator !=(RaycastQuery, RaycastQuery)

    Comapres for inequality. Same as !Equals(RaycastQuery).

    Declaration
    public static bool operator !=(RaycastQuery lhs, RaycastQuery rhs)
    Parameters
    Type Name Description
    RaycastQuery lhs

    The left-hand side of the comparison.

    RaycastQuery rhs

    The right-hand side of the comparison.

    Returns
    Type Description
    bool

    true if any of the fields of this RaycastQuery are not equal to other.

    Implements

    IEquatable<T>
    In This Article
    Back to top
    Copyright © 2025 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)