cancel
Showing results for 
Search instead for 
Did you mean: 

Separating tap from double tap

mallmagician
Expert Protege
No matter what I do, a quick single or whatever, a double tap always registers. 

Here is the code I'm trying to use. 
using UnityEngine;
using UnityEngine.VR;
using System.Collections;

public class DoubleTap2 : MonoBehaviour
{
    private float doubleClickTimeLimit = 0.25f;

    protected void Start()
    {
        StartCoroutine(InputListener());
    }

    // Update is called once per frame
    private IEnumerator InputListener()
    {
        while (enabled)
        { //Run as long as this is activ

            if (Input.GetMouseButtonUp(0))
                yield return ClickEvent();

            yield return null;
        }
    }

    private IEnumerator ClickEvent()
    {
        //pause a frame so you don't pick up the same mouse down event.
        yield return new WaitForEndOfFrame();

        float count = 0f;
        while (count < doubleClickTimeLimit)
        {
            if (Input.GetMouseButtonUp(0))
            {
                DoubleClick();
                yield break;
            }
            count += Time.deltaTime;// increment counter by change in time between frames
            yield return null; // wait for the next frame
        }
        SingleClick();
    }


    private void SingleClick()
    {
        Debug.Log("Single Click");
    }

    private void DoubleClick()
    {
        InputTracking.Recenter();
    }

}

1 ACCEPTED SOLUTION

Accepted Solutions

juanoldinho
Heroic Explorer
Hi,

Have you checked the documentation regarding using the touchpad:
https://developer3.oculus.com/doc/1.11-unity/class_o_v_r_touchpad.html#a787fd5de32818ff630a69a460195...

There is also a forum post that looks to be accomplishing something similar:
https://forums.oculus.com/community/discussion/comment/245572/#Comment_245572
Please tag me, @juanoldinho, in your forum post/response if you need immediate assistance or want additional support or context on an issue you are having with our software or integrations.

Having an issue with our platform, services, or integrations?

Try using our new bug tool to report this and receive emailed updates as we proceed to address it internally.

View solution in original post

1 REPLY 1

juanoldinho
Heroic Explorer
Hi,

Have you checked the documentation regarding using the touchpad:
https://developer3.oculus.com/doc/1.11-unity/class_o_v_r_touchpad.html#a787fd5de32818ff630a69a460195...

There is also a forum post that looks to be accomplishing something similar:
https://forums.oculus.com/community/discussion/comment/245572/#Comment_245572
Please tag me, @juanoldinho, in your forum post/response if you need immediate assistance or want additional support or context on an issue you are having with our software or integrations.

Having an issue with our platform, services, or integrations?

Try using our new bug tool to report this and receive emailed updates as we proceed to address it internally.