Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug WebGL: inconsistent mouse scroll values

Discussion in 'Input System' started by mehmet_soyturk, Jul 19, 2023.

  1. mehmet_soyturk

    mehmet_soyturk

    Joined:
    Oct 17, 2022
    Posts:
    17
    I get inconsistent mouse scroll values on WebGL. I have the impression that touchpad scrolling breaks it.

    This is the setup I have:

    upload_2023-7-19_17-5-40.png

    upload_2023-7-19_17-5-50.png

    Code (CSharp):
    1.  
    2. _controls.Mouse.MouseScrollY.performed += v =>
    3. {
    4.     float value = v.ReadValue<float>();
    5.     UnityEngine.Debug.Log($"Scroll {value}");
    6. };
    Note: I'm on Windows.

    For a desktop build, I get scroll steps of 120 (or -120) from mouse scroll. If I rotate the scroll wheel hard enough, the steps can become multiples of that 120. That is all good and consistent in itself.
    It is also possible to trigger these scroll events by moving two fingers up/down on the touchpad. This time we get a bigger number of scroll events with smaller scroll values. That also works smoothly and consistent with the mouse scroll.

    However, on WebGL, things are different. After starting the application, if I don't touch any touchpad and do my scrolls through mouse only, things are the same as desktop. However, if at app startup I start scrolling with the touchpad, scrolling sensitivity becomes broken. The touchpad scrolling does not feel natural any more. And if I do mouse wheel scrolling afterwards, the scroll amounts are much bigger. I have seen values from 500, 1000, 2000, 4000 (even 12000, see below).

    I have the impression that Unity tries to calibrate the scroll values from the first scroll events. If at app startup, I do touchpad scrolling very quickly, I get relatively small mousewheel scroll steps, like 500. Then, if I repeat mousewheel scrolling continuously, it decreases gradually to 120. [note: that decrease does not happen if I let the application rest for some time].
    Instead, at app startup, I do touchpad scrolling as slow as I can. Values of 120 are reported as scroll values (they should have been much smaller). Then if I do mousewheel scrolling, I get scroll values of 12000! After some time, Unity seemingly detects that 12000 does not makes sense, and jumps back to 120.

    Did anyone have an experience with that?
     
  2. mehmet_soyturk

    mehmet_soyturk

    Joined:
    Oct 17, 2022
    Posts:
    17
    Note: I have tried different action types and control types. It didn't change anything, although I'm not sure I tried all sensible combinations.
     
  3. ricardo_unity506

    ricardo_unity506

    Joined:
    Aug 24, 2023
    Posts:
    1
    Indeed I'm having the exact same issue. Important thing to notice is that I get exactly the same values, 120, 12000, etc for exactly the same cases.
    What I did was to detect this changes in values and create cases, though is not the best option.