Struct RaycastResult | Unity UI | 1.0.0
docs.unity3d.com
    Show / Hide Table of Contents

    Struct RaycastResult

    A hit result from a BaseRaycaster.

    Namespace: UnityEngine.EventSystems
    Syntax
    public struct RaycastResult

    Fields

    depth

    Used by raycasters where elements may have the same unit distance, but have specific ordering.

    Declaration
    public int depth
    Field Value
    Type Description
    Int32

    displayIndex

    The display index from which the raycast was generated.

    Declaration
    public int displayIndex
    Field Value
    Type Description
    Int32

    distance

    Distance to the hit.

    Declaration
    public float distance
    Field Value
    Type Description
    Single

    index

    Hit index

    Declaration
    public float index
    Field Value
    Type Description
    Single

    module

    BaseRaycaster that raised the hit.

    Declaration
    public BaseRaycaster module
    Field Value
    Type Description
    BaseRaycaster

    screenPosition

    The screen position from which the raycast was generated.

    Declaration
    public Vector2 screenPosition
    Field Value
    Type Description
    Vector2

    sortingLayer

    The SortingLayer of the hit object.

    Declaration
    public int sortingLayer
    Field Value
    Type Description
    Int32
    Remarks

    For UI.Graphic elements this will be the values from that graphic's Canvas For 3D objects this will always be 0. For 2D objects if a 2D Renderer (Sprite, Tilemap, SpriteShape) is attached to the same object as the hit collider that sortingLayerID will be used.

    sortingOrder

    The SortingOrder for the hit object.

    Declaration
    public int sortingOrder
    Field Value
    Type Description
    Int32
    Remarks

    For Graphic elements this will be the values from that graphics Canvas For 3D objects this will always be 0. For 2D objects if a 2D Renderer (Sprite, Tilemap, SpriteShape) is attached to the same object as the hit collider that sortingOrder will be used.

    worldNormal

    The normal at the hit location of the raycast.

    Declaration
    public Vector3 worldNormal
    Field Value
    Type Description
    Vector3

    worldPosition

    The world position of the where the raycast has hit.

    Declaration
    public Vector3 worldPosition
    Field Value
    Type Description
    Vector3

    Properties

    gameObject

    The GameObject that was hit by the raycast.

    Declaration
    public GameObject gameObject { get; set; }
    Property Value
    Type Description
    GameObject

    isValid

    Is there an associated module and a hit GameObject.

    Declaration
    public bool isValid { get; }
    Property Value
    Type Description
    Boolean

    Methods

    Clear()

    Reset the result.

    Declaration
    public void Clear()

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    String
    Overrides
    ValueType.ToString()
    Back to top Copyright © 2020 Unity Technologies
    Generated by DocFX
    on October 6, 2020