Page 1 of 1

Unity bug when scrolling on touchpad

Posted: 21 Jul 2016, 11:16
by ivan_b
In unity on windows version there is a problem when scrolling with the touchpad.
It is possible to get the scroll delta but inside the OnGUI method.
I have added these code snippet in the ProcessEvent method in NoesisUIRenderer and it solves the problem
case UnityEngine.EventType.scrollWheel:
{
UnityEngine.Vector2 mouse = ProjectPointer(ev.mousePosition.x,UnityEngine.Screen.height - ev.mousePosition.y);
Noesis_MouseWheel ( _rendererId, mouse.x, mouse.y, (int)UnityEngine.Event.current.delta.y);
break;
}
I wanted to verify if this can intefere when processing other events?

Re: Unity bug when scrolling on touchpad

Posted: 22 Jul 2016, 16:04
by sfernandez
Do you mean that using the touch pad to scroll doesn't generate values for the Input.GetAxis("Mouse ScrollWheel")?

If that is the case, we should probably abandon that path and use only the EventType.ScrollWheel event from OnGUI only. I can't remember if we didn't use it for any good reason, we will investigate it.

Meanwhile, if you modify the code, you should write something like this:
switch (ev.type)
{
    case UnityEngine.EventType.ScrollWheel:
    {
        if (enableMouse)
        {
            int mouseWheel = -(int)(ev.delta.y * 10.0f);
            if (mouseWheel != 0)
            {
                UnityEngine.Debug.Log(mouseWheel);
                UnityEngine.Vector2 mouse = ProjectPointer(ev.mousePosition.x,
                    UnityEngine.Screen.height - ev.mousePosition.y);
                Noesis_MouseWheel(_rendererId, mouse.x, mouse.y, mouseWheel);
            }
        }
        break;
    }
    //...
}

Re: Unity bug when scrolling on touchpad

Posted: 22 Jul 2016, 17:35
by ivan_b
It does not, there were some topics on unity forums about this.
I have a keyboard with a touchpad where the input is generated
and a laptop with the touchpad where the input is not generated.
Thanks for the help.