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

Bug Working together with UIDocument in world space and IMGUI-elements

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

  1. herra_lehtiniemi

    herra_lehtiniemi

    Joined:
    Feb 12, 2017
    Posts:
    114
    I have an UIDocument that seems to add some stuff to my EventSystem-object. However, after it has added these things, none of the IMGUI-components receive events anymore. Maybe relevant: in my scenario, the UIDocument is rendered fullscreen and the scene GameObjects show through of certain points. But as I understood, UIToolkit doesn't block raycasts anyway in current version? What is the secret to make UIToolkit work together with IMGUI? Unity 2022.1.0a15
     
  2. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    653
    Do you have a Visual Element taking the full screen that has its picking mode set to "position"? If so, that would mean the Visual Element is getting the events. Setting picking mode to "none" will solve it, if that's the case.

    You can check on the UI Builder:

    Screen Shot 2021-12-06 at 22.04.41.png
     
  3. herra_lehtiniemi

    herra_lehtiniemi

    Joined:
    Feb 12, 2017
    Posts:
    114
    Thank you very much. This solved it. There is actually a bug - when using TwoPaneSplitView (which I was using), setting picking mode doesn’t set it to the inner containers this element creates and therefore picking mode ignore has no effect. One has to set those manually by query by class.
     
  4. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    301
    In think that is intentional.
    Image having a transparent UI with some buttons on it. You want to set the container VisualElement to ignore, but the buttons in there should still be clickable.
     
  5. herra_lehtiniemi

    herra_lehtiniemi

    Joined:
    Feb 12, 2017
    Posts:
    114
    Yes actually this was my case: I set the twopane to ignore and set all the stuff inside it to ignore as well but they weren’t transparent (click-wise). Not until I queried the containers that TwoPaneSplitView had created automatically inside it and set them to ignore. It seems to create two container elements for the panes that do not inherit ignore even if the actual TwoPaneSplitView-element is ignore. This means you can’t make anything inside TwoPaneSplitView to ignore via UXML but you must do it via script with this hacky method. So in your example - if you would have a transparent container inside TwoPaneSplitView and a button inside it, even if you would set TwoPaneSplitView and the transparent container to Ignore, they wouldn’t be click-transparent because the invisible containers are inaccessible. They would all block clicks despite the Ignore-parameter until you would force the invisible containers to Ignore as well via script.
     
unityunity