【发布时间】:2015-08-20 01:10:30
【问题描述】:
如何检测 Gear Vr 中的点击以进行操作
我使用 Unity 5 和 C# 编程语言
我的尝试
我在 untiy3d 论坛上阅读了答案
它们都不适合我
http://forum.unity3d.com/threads/samsung-gear-vr-detect-tap-swipe.298346/
任何建议
【问题讨论】:
标签: c# input unity3d oculus unity5
如何检测 Gear Vr 中的点击以进行操作
我使用 Unity 5 和 C# 编程语言
我的尝试
我在 untiy3d 论坛上阅读了答案
它们都不适合我
http://forum.unity3d.com/threads/samsung-gear-vr-detect-tap-swipe.298346/
任何建议
【问题讨论】:
标签: c# input unity3d oculus unity5
您必须自己实现点击(或者实际上是点击,因为触摸板就像鼠标一样工作)。点击是触摸/鼠标向下,然后在相对相同的位置触摸/鼠标向上。
这里有一些应该可以工作的未经测试的代码(如果不行就调用):
using UnityEngine;
public class ClickDetector:MonoBehaviour {
public int button=0;
public float clickSize=50; // this might be too small
void ClickHappened() {
Debug.Log("CLICK!");
}
Vector3 pos;
void Update() {
if(Input.GetMouseButtonDown(button))
pos=Input.mousePosition;
if(Input.GetMouseButtonUp(button)) {
var delta=Input.mousePosition-pos;
if(delta.sqrMagnitude < clickSize*clickSize)
ClickHappened();
}
}
}
【讨论】:
感谢@chanibal,我找到了答案
Input.GetMouseButtonDown(0)
但我面临另一个问题,应用程序迷恋
Gear VR 是否有任何自定义配置
【讨论】:
Input.GetMouseButtonDown(0) 不区分轻击和滑动。对于崩溃,您必须提供比这更多的信息(在单独的问题中执行此操作)。