02-02-2017 08:17 PM
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(); }
}
Solved! Go to Solution.
02-13-2017 11:57 AM
02-13-2017 11:57 AM