Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Feature Request UIDocument and Raycast-blocking

Discussion in 'UI Toolkit' started by herra_lehtiniemi, Dec 5, 2021.

  1. herra_lehtiniemi

    herra_lehtiniemi

    Joined:
    Feb 12, 2017
    Posts:
    114
    Is there yet any built-in way to make UIDocument rendering an UI Toolkit interface in Worldspace block Raycasts? Currently if I have any GameObjects under the UI, all the clicks in the UI go through and trigger unwanted things. How can I "block out" the world behind the UI so only UI would receive clicks? It would be really nice to have a single checkbox "Raycast target", which would block everything from going through.
     
  2. unity_BFEF279E8A0CAC326229

    unity_BFEF279E8A0CAC326229

    Joined:
    Dec 2, 2021
    Posts:
    1
    Maybe you could leverage the Trickle Down and Bubble Up phases to know if the mouse event was used this frame, then block raycasts from occuring.
     
  3. sebastiend-unity

    sebastiend-unity

    Unity Technologies

    Joined:
    Nov 9, 2015
    Posts:
    180
    At worst I don't know but a transparent VisualElement underneath all other UI elements that would eat all input events could be inserted (display = flex, but background-image = rgba(0, 0, 0, 0)).