0
\$\begingroup\$

Is it possible to separately detect the finger close and open gestures (air tap "down" and "up") with Unity (2019) for the Hololens, without using MRTK (it introduces too many portability issues in this project, unfortunately)?

I can detect just a tap (basically just the "up" event) with the UnityEngine.XR.WSA.Input.GestureRecognizer no problem:

public class TapTest : MonoBehaviour {

    private GestureRecognizer gr;

    private void Start () {
        gr = new GestureRecognizer();
        gr.SetRecognizableGestures(GestureSettings.Tap);
        gr.Tapped += OnTap;
        gr.StartCapturingGestures();
    }

    private void OnTap (TappedEventArgs args) {
        print($"OnTap {args.source.kind}");
    }

}

That prints the expected messages on an air tap.

But I'm not really sure how to detect the initial "down" part of the gesture (the pinch), if it's even possible, although I feel like it should be possible since the hololens itself adjusts it's cursor icon immediately on pinch.

I found this page and thought maybe from there that Hold or Manipulation start events would be triggered at the initial pinch gesture, but I added similar handlers for those gestures and found that neither are triggered until HoldStartDuration is reached, which I guess makes sense in retrospect.

I'm also looking through the MRTK source but I'm getting confused by all the layers of abstraction and having a lot of trouble tracing through it, so I wasn't really able to find what I was looking for.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.