IEnumerator singleOrDouble ()
{
yield return new WaitForSeconds (0.3f);
if (touch.tapCount == 1)
//Debug.Log ("Single");
OnSingleTapped ();
else if (touch.tapCount == 2) {
//this coroutine has been called twice. We should stop the next one here otherwise we get two double tap
StopCoroutine ("singleOrDouble");
//Debug.Log ("Double");
OnDoubleTapped();
}
}
//
private void OnSingleTapped ()
{
TriggerAutoFocus ();
//label = "Tap the Screen!";
}
private void OnDoubleTapped ()
{
//label = "Double Tap the Screen!";
}
//SingleTap Gestures are captured by AppManager and calls this method for TapToFocus
public void TriggerAutoFocus ()
{
StartCoroutine (TriggerAutoFocusAndEnableContinuousFocusIfSet ());
}
/// <summary>
/// Activating trigger autofocus mode unsets continuous focus mode (if was previously enabled from the UI Options Menu)
/// So, we wait for a second and turn continuous focus back on (if options menu shows as enabled)
/// </returns>
private IEnumerator TriggerAutoFocusAndEnableContinuousFocusIfSet ()
{
CameraDevice.Instance.SetFocusMode (CameraDevice.FocusMode.FOCUS_MODE_TRIGGERAUTO);
yield return new WaitForSeconds (1.0f);
CameraDevice.Instance.SetFocusMode (CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
}