检测三星Gear VR中的水龙头

Min*_*wzy 2 c# input unity-game-engine oculus unity5

如何在Gear Vr中检测水龙头以进行操作

我使用Unity 5和C#编程语言

我的尝试

我在untiy3d论坛上阅读答案

他们都没有对我有用

http://forum.unity3d.com/threads/samsung-gear-vr-detect-tap-swipe.298346/

有什么建议

Krz*_*rko 6

您必须自己实现点击(或实际上是点击,因为触摸板可用作鼠标).轻击是触摸/鼠标按下,然后触摸/鼠标在相对相同的位置.

这是一些应该工作的未经测试的代码(如果没有则调用):

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();
      }
    }
}
Run Code Online (Sandbox Code Playgroud)