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.
The mousewheel events are registered in the pink boxes below:
(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?
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
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!
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!