Using: Unity 2018.4.1 LTS & Oculus GO
I am using a gaze pointer to interact with Unity UI.
This is supposed to happen when you pull the trigger, exactly how I defined it in my script: a swipe left or right on the touchpad of the go-controller however triggers clicks as well. I did not define this myself, it's just a thing that happens and I can not figure out how to work around it.
I found and fiddled around with solutions proposed in this thread and this thread.
However, none of these solutions provided me a way to get rid of these swipe clicks while keeping alive index trigger clicks.
My Input Manager (Index Trigger Interaction with UI seems to happen in OVRInputModule):
private void Update()
{
if (OVRInput.GetDown(OVRInput.Button.PrimaryTouchpad) || OVRInput.GetDown(OVRInput.Button.Two))
{
ToggleVidInterface();
}
if (OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger))
{
StartCoroutine(TouchpadCounter());
}
}
IEnumerator TouchpadCounter()
{
int secondsForCounting = 2;
float startTime = Time.time;
int touchCount = 0;
while (Time.time - startTime <= secondsForCounting && OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger))
{
if (OVRInput.GetDown(OVRInput.Button.PrimaryTouchpad))
{
touchCount++;
Debug.Log("touchCount for Admin Menue: " + touchCount);
}
if (touchCount >= 3)
{
ActivateAdminMenue();
}
yield return null;
}
yield return null;
}
Part of the OVRInputModule (I don't know if its the right part):
/// <summary>
/// Get state of button corresponding to gaze pointer
/// </summary>
/// <returns></returns>
virtual protected PointerEventData.FramePressState GetGazeButtonState()
{
var pressed = Input.GetKeyDown(gazeClickKey) || OVRInput.GetDown(joyPadClickButton);
var released = Input.GetKeyUp(gazeClickKey) || OVRInput.GetUp(joyPadClickButton);
#if UNITY_ANDROID && !UNITY_EDITOR
// On Gear VR the mouse button events correspond to touch pad events. We only use these as gaze pointer clicks
// on Gear VR because on PC the mouse clicks are used for actual mouse pointer interactions.
pressed |= Input.GetMouseButtonDown(0);
released |= Input.GetMouseButtonUp(0);
#endif
if (pressed && released)
return PointerEventData.FramePressState.PressedAndReleased;
if (pressed)
return PointerEventData.FramePressState.Pressed;
if (released)
return PointerEventData.FramePressState.Released;
return PointerEventData.FramePressState.NotChanged;
}
Messing with the Android if condition just enables or disables clicking as a whole (trigger and touchpad). What am I missing here? How can I seperate between a trigger click and a touchpad swipe?!
Just found it out:
katbot's answer is one of two parts to separate Trigger Click from Touchpad swipe Click.
First comment out in OVRInputModule.cs
like so:
virtual protected PointerEventData.FramePressState GetGazeButtonState()
{
var pressed = Input.GetKeyDown(gazeClickKey) || OVRInput.GetDown(joyPadClickButton);
var released = Input.GetKeyUp(gazeClickKey) || OVRInput.GetUp(joyPadClickButton);
// 👇 Comment out or remove this block, because it causes touchpad touch events to register as click events.
// #if UNITY_ANDROID && !UNITY_EDITOR
// On Gear VR the mouse button events correspond to touch pad events. We only use these as gaze pointer clicks
// on Gear VR because on PC the mouse clicks are used for actual mouse pointer interactions.
//pressed |= Input.GetMouseButtonDown(0);
//released |= Input.GetMouseButtonUp(0);
// #endif
if (pressed && released)
return PointerEventData.FramePressState.PressedAndReleased;
if (pressed)
return PointerEventData.FramePressState.Pressed;
if (released)
return PointerEventData.FramePressState.Released;
return PointerEventData.FramePressState.NotChanged;
}
THEN go to your OVRInputModule
in UnityEditor. Under "Joy Pad Click Button" now choose "Primary Index Trigger". Now you have killed the touchpad swipe click by commenting out the Input.GetMouseButtonDown(0)
stuff, which kills normal Trigger Clicks as well. But we can bring them back by linking them to the "Joy Pad Click Button" in Unity Editor.