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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Bug Scrolling using mouse wheel is not working in latest unity 2022.2.0f1

Discussion in 'UI Toolkit' started by Maverick, Dec 13, 2022.

  1. Maverick

    Maverick

    Joined:
    Dec 18, 2009
    Posts:
    225
    Tested ScrollView, ListView, MultiColumnListView, MulticolumnTreeView in 2022.1.24 and scroll using mouse wheel is working as expected.

    It does not work in 2022.2.0f1. Did something changed in how scrolling work and there is a new setting somewhere (didn't find anything in release notes)?

    Thanks.
     
    Last edited: Dec 13, 2022
    sharkbitgamesdev likes this.
  2. Maverick

    Maverick

    Joined:
    Dec 18, 2009
    Posts:
    225
    After digging a bit more, it might be WheelEvent's problem. Using event debugger I'm getting following in 2022.2.0f1:

    upload_2022-12-13_13-51-33.png

    Here is same event in 2022.1.24f1:

    upload_2022-12-13_13-53-10.png

    Any advise, workaround?
     
    sharkbitgamesdev likes this.
  3. Steve2375

    Steve2375

    Joined:
    Mar 28, 2015
    Posts:
    42
    I experience the same problem. Any feedback from Unity when this will get fixed?
     
  4. Maverick

    Maverick

    Joined:
    Dec 18, 2009
    Posts:
    225
    Steve2375 likes this.
  5. ldaughtry

    ldaughtry

    Joined:
    Oct 30, 2012
    Posts:
    38
    Is there a timeline on a fix for this? I can't see that jira ticket linked above.
    2022.2.2 does not fix it.
     
  6. noirb

    noirb

    Joined:
    Apr 10, 2014
    Posts:
    84
    Weird: after upgrading my project from 2021 to 2022.2, I'm just not getting WheelEvents at all (even the event debugger doesn't show any, but all other mouse events seem to work fine). But mousewheel scrolling does appear to work fine if I create a new empty project...

    EDIT: My bad: WheelEvents ARE being fired, they just weren't selected by default in the event debugger so I missed them. But as above,
    Mouse delta
    is always
    (0, 0, 0)
    :
    upload_2023-1-17_23-13-27.png

    Additionally, my empty test project was accidentally created with Unity 2021.x, after creating a new one with 2022.2 I see the same behavior in a new empty project, as well :(
     
    Last edited: Jan 17, 2023
  7. noirb

    noirb

    Joined:
    Apr 10, 2014
    Posts:
    84
    While looking for a workaround, I found that mouse wheel information isn't completely broken in 2022:
    Code (CSharp):
    1. element.RegisterCallback<WheelEvent>((evt) => {
    2.     Debug.LogFormat("WheelEvent.delta: {0}, mouseDelta: {1}, Input.GetAxis: {2}",
    3.                     evt.delta, evt.mouseDelta, Input.GetAxis("Mouse ScrollWheel"));
    4. }
    5.  
    In 2021.x, the output shows that
    delta.y == mouseDelta.y
    :
    WheelEvent.delta: (0.00, 3.00, 0.00), mouseDelta: (0.00, 3.00), Input.GetAxis: -1


    In 2022.2,
    delta.y
    is always
    0
    , but
    mouseDelta.y == Input.GetAxis("Mouse ScrollWheel")
    :
    WheelEvent.delta: (0.00, 0.00, 0.00), mouseDelta: (0.00, 1.00), Input.GetAxis: 1


    Also a little interesting: with mice that allow left/right inputs on the wheel, this does NOT appear to trigger a
    WheelEvent
    in Unity 2021.x, but in 2022.2 it does fire with a non-zero value in
    mouseDelta.x
    (both
    delta
    and
    Input.GetAxis
    were zero).

    In our custom elements which relied on mouse wheel input, we had previously been using
    WheelEvent.delta.y
    , but it seems we can safely change this to
    mouseDelta.y
    (although the magnitude is different so we've got to adjust our sensitivity settings).

    It's not clear to me whether this is an expected breaking change and everything (including Unity-provided UIElements like the ScrollView) should switch over to using
    mouseDelta
    (according to the official documentation it seems we should still expect
    delta
    to be the way to go), but this also means that it's possible to implement a (hacky) workaround for the time being (but if in a future release ScrollView starts to scroll on its own again, I fully expect this to cause problems):

    Code (CSharp):
    1.             listView = root.Q<ListView>("ListView");
    2.             var sv = listView.Q<ScrollView>();
    3.             sv.RegisterCallback<WheelEvent>((evt) =>
    4.             {
    5.                 sv.scrollOffset -= evt.mouseDelta * 10f;
    6.             });
     
    Last edited: Jan 18, 2023
  8. Maverick

    Maverick

    Joined:
    Dec 18, 2009
    Posts:
    225
  9. johfirefly

    johfirefly

    Joined:
    Aug 21, 2018
    Posts:
    14
    Excellent. It remains to find out how to download version 2022.2.3f1 :)
     
  10. Maverick

    Maverick

    Joined:
    Dec 18, 2009
    Posts:
    225
    So, 2022.2.3 is out and you can install it via Hub. The scroll issue is fixed, BUT it now scrolls in the opposite direction as before. In 2022.1.x it scrolls down, now it scrolls up.

    Is it intentional? Is there an option for UI Toolkit to invert scroll direction?

    Thanks.
     
    johfirefly likes this.
  11. ldaughtry

    ldaughtry

    Joined:
    Oct 30, 2012
    Posts:
    38
    Came here to report the same *point_up*

    I can't find an option to invert the scroll direction.
     
    johfirefly likes this.
  12. toddhdavis

    toddhdavis

    Joined:
    Oct 18, 2018
    Posts:
    7
    I dunno, I'm using 2022.3.3f1 LTS and it is not scrolling for me using the mouse wheel, at all. :(
     
  13. Marcos-Elias

    Marcos-Elias

    Joined:
    Nov 1, 2014
    Posts:
    158
    Is Input.mouseScrollDelta working for you?
    The code I was using stopped working after upgrading from 2020.3 to 2022.3.4f1. I tried this mouseScrollDelta but I see no change. Even Input.GetAxis("Mouse X") or "Mouse Y" is broken here, same code works with 2020.3 but not 2022.3.

    I tested it with this code:

    Code (CSharp):
    1. void Update()
    2.     {
    3.         Debug.Log("Mouse X: " + Input.GetAxis("Mouse X").ToString() + " Mouse Y: " + Input.GetAxis("Mouse Y").ToString() + " Mouse Scrollwheel: " + Input.GetAxis("Mouse ScrollWheel") + " Mouse mouseScrollDelta: " + Input.mouseScrollDelta.y);
    4.     }
    Result (attached image)

    Same results in a new project. When I move the mouse very fast some values are shown but they go back to zero the next frame.
     

    Attached Files:

    Last edited: Jul 9, 2023