gpt4 book ai didi

android - 在 Oculus GO Touchpad 上滑动会在不应该触发 UI 点击

转载 作者:搜寻专家 更新时间:2023-11-01 08:17:59 24 4
gpt4 key购买 nike

使用:统一 2018.4.1 LTS &眼环GO

我正在使用注视点与 Unity UI 交互。

这应该在您扣动扳机时发生,这正是我在脚本中定义的方式:在 go-controller 的触摸板上向左或向右滑动,但也会触发点击。我自己没有定义它,这只是发生的事情,我不知道如何解决它。

我发现并研究了 this thread 中提出的解决方案和 this thread .

但是,这些解决方案都没有为我提供一种方法来摆脱这些滑动点击,同时保持索引触发点击。

我的输入管理器(与 UI 的索引触发器交互似乎发生在 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;
}

OVRInputModule 的一部分(不知道对不对):

        /// <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;
}

如果条件只是启用或禁用整个点击(触发器和触摸板),则与 Android 打交道。我在这里错过了什么?如何区分触发点击和触摸板滑动?!

最佳答案

我也遇到了这个问题,我通过注释掉 OVRInputModule.GetGazeButtonState() 的一部分解决了这个问题,如下所示:

        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;
}

关于android - 在 Oculus GO Touchpad 上滑动会在不应该触发 UI 点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56445439/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com