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. Dismiss Notice

Resolved Combine uGUI & UI Toolkit

Discussion in 'UI Toolkit' started by Sergey_ksubox, Sep 4, 2021.

  1. Sergey_ksubox

    Sergey_ksubox

    Joined:
    Jul 29, 2015
    Posts:
    26
    Hello,
    I had to combine old uGUI interface & new UI Toolkit dialogs, but meet the problem:
    All mouse event go to uGUI elements and UI Toolkit gets mouse event only if no uGUI elements behind it (Rendering order is ok).
    I wonder how to put UI Toolkit "in front" of uGUI Canvas in terms of mouse event processing ?
    upload_2021-9-4_21-42-18.png
     
  2. AlexandreT-unity

    AlexandreT-unity

    Unity Technologies

    Joined:
    Feb 1, 2018
    Posts:
    323
    What is the render mode of you uGUI Canvas?
     
  3. Sergey_ksubox

    Sergey_ksubox

    Joined:
    Jul 29, 2015
    Posts:
    26
    I tried Screen Space Overlay & Screen Space Camera - both don't work.
    Temporary I found solution - disable Graphic Raycaster component of Canvas object when show UI Toolkit dialog and enable back when close dialog. But I expect more elegant solution.
     
  4. AlexandreT-unity

    AlexandreT-unity

    Unity Technologies

    Joined:
    Feb 1, 2018
    Posts:
    323
    Did you try changing the sort order of the uitoolkit panel settings vs canvas?
     
    v-strelchenko likes this.
  5. Sergey_ksubox

    Sergey_ksubox

    Joined:
    Jul 29, 2015
    Posts:
    26
    Yes I tried. Originally Canvas & UIDocument objects had UI Layer & Order == 0.
    Setting UIDocument Order to 1 (or 2, 3,...) didn't help.
    And what I also found:
    - If Canvas Order == 0 and UIDocuments Order > 0 all mouse events go to Canvas and UIDocuments rendered in front of canvas
    - If Canvas Order > 0 and UIDocuments Order > 0 all mouse events go to Canvas and UIDocuments rendered behind canvas even UIDocuments Order > Canvas Order!

    Looks like Order of UIDocuments doesn't matter ! It always use 0 Order.

    But after your mail I decided to check one stupid idea - if we can't change Order for UIDocument from 0 may be Canvas Order == -1 help. So I set it to -1 and it WORKS!

    So thank you very much for your reply.
    And, please ask developers to fix that bug/"feature" with UIDocument to enable Sort Order management.
     
  6. AlexandreT-unity

    AlexandreT-unity

    Unity Technologies

    Joined:
    Feb 1, 2018
    Posts:
    323
    Could you go in Help > Report a Bug... and submit a bug report with a small repro of the issue? It would help a lot. Thanks
     
  7. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    733
    Be sure to look at the Panel Settings asset Sort Order, not the UI Document's.
    UI Document sort order sorts them inside a single panel. The Panels & Canvases are the ones that can get sorted together.
     
    hayricakir likes this.