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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question MouseWheel Events not registering in the right place

Discussion in 'UI Toolkit' started by osaharoy, Jul 22, 2020.

  1. osaharoy

    osaharoy

    Joined:
    May 6, 2020
    Posts:
    5
    I have a few text fields that I want to be able to mouse over and change the value of by scrolling. It works ok, except that the MouseWheel events are not registered when I'm directly over the element I'm interested in.

    scrolling.gif

    The mousewheel events are registered in the pink boxes below:

    UI.png

    (Those pink boxes are the position of the VisualElement.worldBound for each text field)

    When I set the UIDocument scaling to Constant Pixel size, everything works as I want. When I set it to anything else, the pink boxes no longer align with the actual text fields and the wheel events are registered in the wrong place :( how do I make it work with scaling?
     
  2. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    Hey there, can we take a look at your UXML? That could help us diagnose what's going on :)
     
  3. osaharoy

    osaharoy

    Joined:
    May 6, 2020
    Posts:
    5
    Thanks for the help :) I've made a little test scene, made on unity version 2020.1.0b14.4034, UI Toolkit version 1.0.0-preview.3

    I think the issue is to do with the UI Document panel scaling because it doesn't happen when the panel is set to constant pixel size - the panel in this example is set to constant physical size. I should maybe also mention I'm using a 4k monitor, so that might affect how things work

    What you should see:
    When scrolling in the blue box, mouse enter and mouse leave events are generated
    When scrolling a bit up and to the left of the box, mouse enter, mouse leave and wheel events are generated

    Hopefully this shows the problem, let me know if there's anything else I can do :)

    edit: I just downloaded the scene and tried to run it, you might need to drag the UXML document and panel settings asset into the UIDocument GameObject's slots as I think they can get disconnected
     

    Attached Files:

  4. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    Hey @osaharoy, I think I see what you're describing here but I don't know what's up. I'm getting more internal people involved, hopefully we can get an answer as to whether it's a bug or we're missing something :)
    We'll keep you posted!
     
  5. osaharoy

    osaharoy

    Joined:
    May 6, 2020
    Posts:
    5
    Thanks so much Julia :)

    Some more info for you: if I set the reference dpi on the panel settings to 144 (which is the value printed by Screen.dpi) then everything works ok. But this gives identical scaling to just using constant pixel size, so I'm not sure it's a workaround but maybe might help you figure stuff out.

    edit: another thing, I had the reference dpi on the panel set to 96, which is 2/3rds of 144. I found that those pink boxes in the image I posted above are exactly 2/3rds the scale of what they should be. I'm not sure how this helps but it seems relevant. Thanks for the help!
     
  6. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    That sounds relevant indeed @osaharoy, thanks for sharing!