ivan_b
Topic Author
Posts: 87
Joined: 22 Jul 2015, 12:57

Unity bug when scrolling on touchpad

21 Jul 2016, 11:16

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?
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: Unity bug when scrolling on touchpad

22 Jul 2016, 16:04

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;
    }
    //...
}
 
ivan_b
Topic Author
Posts: 87
Joined: 22 Jul 2015, 12:57

Re: Unity bug when scrolling on touchpad

22 Jul 2016, 17:35

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.

Who is online

Users browsing this forum: No registered users and 1 guest