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

Question Canvas buttons not working if UI Toolkit's Panel Raycaster is active?

Discussion in 'UI Toolkit' started by Hexane, Aug 28, 2023.

  1. Hexane

    Hexane

    Joined:
    Jan 23, 2018
    Posts:
    16
    I'm using the new Input System with UI Toolkit for my menu overlay in my project. I have world space buttons in a Canvas that aren't registering mouse events like clicking and hovering. I've tried a couple things but I can't find a solution. It seems that someone else is struggling, too, but maybe we're doing something wrong.

    I've noticed that the EventSystem GO with the InputSystemUIInputModule component creates a child object at runtime named "MainMenu Panel Settings" with a `Panel Raycaster (UI Toolkit)` component. If I disable just the Panel Raycaster component, the clicks go through to the Canvas but it naturally disables my UI Toolkit menu overlay.

    Among the things I've tried include:
    - Setting my Active Input Handling to "Input System Package (new)"
    - Playing with the sort order of my Canvas and my UI Toolkit (both in the GO and the UI panels setting asset)

    Does anybody know what I may be doing wrong?

    Unity 2022.3.8f1
    Unity UI 1.0.0
    Input System 1.6.3
     
  2. Hexane

    Hexane

    Joined:
    Jan 23, 2018
    Posts:
    16
    I figured it out. It turns out that my UI document had some invisible sections for scaffolding that had their Picking Mode attribute set to "Position" instead of "Ignore", so the event was being intersected and never reaching the Canvas. :^)
     
  3. theprojectzero

    theprojectzero

    Joined:
    Apr 12, 2017
    Posts:
    1
    Hi! What exactly did you do to fix it? I have the same issue, i did try making uidocument SortOrder =1 and canvas sortOrder = 2, but the button events on the canvas don't fire still.
     
  4. Hexane

    Hexane

    Joined:
    Jan 23, 2018
    Posts:
    16
    I messed around with the settings and left the UI sort order on 0 and set the Canvas's Oder in Layer to 1 which seemed to solve all the overlapping issues. But that doesn't seem to matter for the mouse events and it's only cosmetic from what I've seen.

    What finally solved it was opening the UI Editor and checking to see if there were any transparent Visual Elements that were overlapping the screen. And one by one, I set their "Picking Mode" attribute to "Ignore" in the right-hand panel under the Attributes section near the top.

    The image attached shows the areas I'm using to organize the UI like a web page. All the other elements like the gear button shown in the red area have their Picking Mode set to "Position". They'll still capture the mouse events even if they're within a parent visual element that's set to ignore. I don't think "picking mode" is a very descriptive name here but that's what did it.
     

    Attached Files:

  5. simonmonkeyz

    simonmonkeyz

    Joined:
    Jan 31, 2022
    Posts:
    2
    Just adding on to this problem where mine was simply other invisible but active game objects blocking the interactable path for pressing the buttons.....:oops: