docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct RaycastResult

    A hit result from a BaseRaycaster.

    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.EventSystems
    Assembly: UnityEngine.UI.dll
    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
    int

    displayIndex

    The display index from which the raycast was generated.

    Declaration
    public int displayIndex
    Field Value
    Type Description
    int

    distance

    Distance to the hit.

    Declaration
    public float distance
    Field Value
    Type Description
    float

    index

    Hit index

    Declaration
    public float index
    Field Value
    Type Description
    float

    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

    sortingGroupID

    The sorting group ID when the hit object is influenced by a SortingGroup.

    Declaration
    public int sortingGroupID
    Field Value
    Type Description
    int
    Remarks

    For UI.Graphic elements will always be 0. For 3D objects this will always be 0. For 2D objects if a SortingOrder is influencing the same object as the hit collider then the renderers sortingGroupID will be used; otherwise SortingGroup.invalidSortingGroupID.

    sortingGroupOrder

    The sorting group order when the hit object is influenced by a SortingGroup.

    Declaration
    public int sortingGroupOrder
    Field Value
    Type Description
    int
    Remarks

    For UI.Graphic elements this will always be 0. For 3D objects this will always be 0. For 2D objects if a SortingOrder is influencing the same object as the hit collider then the renderers sortingGroupOrder will be used.

    sortingLayer

    The SortingLayer of the hit object.

    Declaration
    public int sortingLayer
    Field Value
    Type Description
    int
    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
    int
    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
    bool

    Methods

    Clear()

    Reset the result.

    Declaration
    public void Clear()

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    ValueType.ToString()
    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)