2

I have a Scroll View containing few buttons as child elements under content-panel. Hierarchy looks like this:

I have implemented OVRTouchpad.TouchHandler event like this on my script attached to ScrollView:

void Start()
{
    #if OVR && !UNITY_EDITOR
    OVRTouchpad.Create();
    OVRTouchpad.TouchHandler += HandleTouchHandler;
    #endif
}

void HandleTouchHandler (object sender, System.EventArgs e)
{
    OVRTouchpad.TouchArgs touchArgs = (OVRTouchpad.TouchArgs)e;
    if(touchArgs.TouchType == OVRTouchpad.TouchEvent.Left || touchArgs.TouchType == OVRTouchpad.TouchEvent.Up)
    {
        // Code to scroll UP for swipe in directions LEFT/UP
    }
    else if(touchArgs.TouchType == OVRTouchpad.TouchEvent.Right || touchArgs.TouchType == OVRTouchpad.TouchEvent.Down)
    {
        // Code to scroll DOWN for swipe in directions RIGHT/DOWN
    }
}

Problem :

As I am using OVR Input Muodule, it processes Tap input even if I try to swipe. So every time I swipe in any direction while gazing at button (child of scroll view). Button is clicked taking me to some other menu. I am not sure if this is desired behaviour of Gear VR Input system. As I have seen in Oculus Home App (and other apps on store) it only scrolls without triggering clicks on child element.

Is there any way to prevent click/tap if swipe is detected?

Any kind of help is highly appreciated.

Umair M
  • 10,298
  • 6
  • 42
  • 74

1 Answers1

0

Have you tried inserting an IF statement to handle the singletap trigger first?

  if(touchArgs.TouchType == OVRTouchpad.TouchEvent.SingleTap)
  {
     //TODO: Nest IF statements here checking conditions which indicate swipe instead of tap. If nothing further detected, process single tap. 
     //Otherwise continue with swipe direction handling.
  }

But that being said using the VRInput script mentioned in this tutorial would probably be your best bet as it can handle swipes with direction input too.

https://unity3d.com/learn/tutorials/topics/virtual-reality/interaction-vr

Snippit:

public event Action<SwipeDirection> OnSwipe;                // Called every frame passing in the swipe, including if there is no swipe.
LJ Codes
  • 116
  • 9
  • 1
    I face problem because event system is receiving tap just like mouse-click if pointer is on some button. I want to prevent that. – Umair M Oct 19 '16 at 13:04
  • Either you intervene with that tap trigger and handle it or use a different event system/method. The VR Input definitely looks the most promising for better control. It records the position of the finger when on the touchpad and when it is released to determine if it was a swipe or a tap. Just like you need. – LJ Codes Oct 19 '16 at 13:59
  • I can't use a different event system when working with Unity UI. If don't have choice to create manual buttons with box colliders. – Umair M Oct 20 '16 at 09:43