Input.mouseScrollDelta
only changes for a physical mouse scroll wheel. It is not changing for a touch-pad two-finger scroll gesture (though the scroll icon does appear and otherwise works in other programs). Input.GetAxis("Mouse ScrollWheel")
has the same effect. Input.touchCount
(or anything touch related) is only for touch screens and doesn't help me make my own scroll check on a touch pad. So I'm out of ideas. How in the world am I supposed to know I'm scrolling on a laptop's touch pad?
Asked
Active
Viewed 1,607 times
3

CodeMonkey
- 1,795
- 3
- 16
- 46
-
Mouse touchpads can work differently as their software often sends the fake commands rather than relying on windows to do it. because they dont have the physical controls – BugFinder Feb 12 '20 at 18:50
-
1[Input.mouseScrollDelta](https://docs.unity3d.com/ScriptReference/Input-mouseScrollDelta.html) includes data from Mac trackpads. I'm not sure if it pulls from windows trackpads as well. – Erik Overflow Feb 12 '20 at 19:43
-
I can at least tell you it doesn't pull from my own Windows machine. – CodeMonkey Feb 12 '20 at 23:02
1 Answers
2
Since you've tagged it Unity3d, maybe this will help you overcome: https://answers.unity.com/questions/356767/how-to-get-scrollwheel-values-using-a-laptop-touch.html
public void OnGUI()
{
if(Event.current.type == EventType.ScrollWheel)
// do stuff with Event.current.delta
Debug.Log(Event.current.delta);
}
The OnGui
documentation can be found here: https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnGUI.html
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
void OnGUI()
{
if (GUI.Button(new Rect(10, 10, 150, 100), "I am a button"))
{
print("You clicked the button!");
}
}
}
OnGUI is called for rendering and handling GUI events.
This means that your OnGUI implementation might be called several times per frame (one call per event). For more information on GUI events see the Event reference. If the MonoBehaviour's enabled property is set to false, OnGUI() will not be called.

Athanasios Kataras
- 25,191
- 4
- 32
- 61
-
Perfect! I would not have expected a scroll input to be an "OnGUI" thing! Thanks! – CodeMonkey Feb 17 '20 at 17:50
-
Really interesting indeed. More so, because it catches all scroll events regardless of source device. – Athanasios Kataras Feb 17 '20 at 22:25