mallmagician
9 years agoExpert Protege
Separating tap from double tap
No matter what I do, a quick single or whatever, a double tap always registers.
Here is the code I'm trying to use.
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(); }
}
- Hi,
Have you checked the documentation regarding using the touchpad:
https://developer3.oculus.com/doc/1.11-unity/class_o_v_r_touchpad.html#a787fd5de32818ff630a69a460195c623
There is also a forum post that looks to be accomplishing something similar:
https://forums.oculus.com/community/discussion/comment/245572/#Comment_245572