Search code examples
c#unity-game-enginemousescrollrect

Scroll Rect scrolls simply due to mouse movement. How to fix it?


Unity 2019.1.0f2

Input System 1.0.2

  1. I create an empty 3D project, then import the Input System into it.
  2. I add EventSystem to the scene.
  3. Then I write a simple script and add it to scene:

    using UnityEngine;
    using UnityEngine.InputSystem;
    
    public class TestScroll : MonoBehaviour
    {
        void Update()
        {
            Debug.Log(Mouse.current.scroll.ReadValue());
        }
    }

  1. Then I run the scene and just move my mouse (don't spin the mouse wheel) and see this in the console:

enter image description here

Also in the documentation for the Input System I found this:

enter image description here

Because of this feature Scroll Rect starts to scroll simply because I move the mouse pointer over it.

How can this be avoided and why is this happening?


Solution

  • It turns out this is a Unity bug: topic