Search Unity

Question Raycast? Line draw?

Discussion in 'UI Toolkit' started by ShadowAngel, Feb 10, 2021.

  1. ShadowAngel

    ShadowAngel

    Joined:
    Aug 7, 2012
    Posts:
    12
    So i have a grid in scrollview. I need to basically do Physics2D.CircleCast from one of the tiles in some direction for some length and get what tiles are hit.
    How would one do this in UIElements?

    And second question, i need to draw a line from one tile to another. How would i do that? I know we can use
    MeshGenerationContext or ImmediateModeElement to draw a line, but problem is both ways are using default sorting order, and i did not find a way to draw anything over visual elements that are further down hierarchy. Any idea how can i achieve this? Code example for drawing line from point A to point B would be welcome.
    And yes i know about this thread. I did try to use code from there, but same problem persists, i can't draw over lower elements.
     

    Attached Files:

    • 1.jpg
      1.jpg
      File size:
      15.1 KB
      Views:
      302
  2. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    398
    The z-order of elements is currently the same as the children order in the hierarchy. If you do myVisualElement.BringToFront() it will move itself to the end of it's parent's children list.