How to make UI Toolkit overlay uGUI raycast?

I wish to set a visual element (a scroll view) on top of my uGUI canvas (old UI system). The problem is that the clicks go through the UI Toolkit scroll view when the uGUI canvas is active and therefore I cannot scroll down. I have already made sure that the picking mode of my scroll view is set to position.

The only way I can get the UI Toolkit visual element to get the clicks is by disabling the raycast in the uGUI canvas. I don’t wish to do this. I want whatever is showing up in the front to get the clicks.

2 Likes

Hello, I have the same question.
I`ve decided to make ingame debug/cheats console using UI Toolkit to master it (game ui is implemented in uGUI completely). UI Toolkit controls draws over uGUI controls, its ok :slight_smile: But I cannot find a way to block clicks/taps by debug console. Clicks is blocked by game ui.
Input is catched by uGUI firstmost and do not process to UI Toolkit buttons. Sort order management on UIDocument and Canvas doesnot help. Canvas always win input.
I’ve found a poor man solution - disable EventSystem effectively disabling all game ui input. UI Toolkit can works without it, but debug console occupies only upper half of display and it be nice to click at available game ui controls below debug console :slight_smile:

Hi joseGuate97, Silentor666,

I’ve tested it on our most recent 2023.2 beta and it seems to work very well (attached unitypackage). Maybe there’s a bug that we’ve fixed and not backported that’s in play here? What version of Unity are you using?

It can help to make sure sort order isn’t the same value for both UI systems (Canvas and PanelSettings), so there’s no possibility of one winning on rendering and the other on input.

8839207–1204255–ugui-uitk-input-forum-question.unitypackage (1.27 MB)

1 Like

Thank you for your answer! I am using Unity 2021.3.12 LTS (not latest .19 because of Burst compiler regression). Active Input Handling setting: Both.
Checked your sample, unfortunately with same results: sort order affects draw order only, but no input handle order. Checked with old Input manager only - no luck.

Make a short video example
https://www.youtube.com/watch?v=2sKSmTQ7EJ0

OK, I’ve reloaded the same package and scene in 2021.2 and I should have used my own advice, hahah, and vary the sortingOrder.

You can fix the problem by setting the Canvas’s sorting order to -1 or by setting the PanelSettings’s sorting order to 1. Note that changing the UIDocument’s sorting order will have no effect. Also note that the sorting order ambiguity bug is resolved on the latest Unity, but thank you for reminding me that we should backport it!

8839801–1204375–ugui-uitk-input-forum-question-2012.2.unitypackage (1.27 MB)

1 Like

Thank you very much, problem is resolved. Yep, I miss the sorting order at PanelSettings :eyes:

I have to do just the opposite.

So I create a uGUI canvas and I want this to overlay a UI Toolkit View. All clicks of the user should be blocked for the UI Toolkit View.
So with the Sorting Order I can display the uGUI canvas over the UI Toolkit View, but unfortunately both views respond to the user’s input.

Does anyone know how I can implement this?