【问题标题】:Detect tap in Samsung Gear VR在 Samsung Gear VR 中检测水龙头
【发布时间】: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


    【解决方案1】:

    您必须自己实现点击(或者实际上是点击,因为触摸板就像鼠标一样工作)。点击是触摸/鼠标向下,然后在相对相同的位置触摸/鼠标向上。

    这里有一些应该可以工作的未经测试的代码(如果不行就调用):

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

    【讨论】:

    • 太棒了!这个脚本附在哪里?
    • 随心所欲,例如到主摄像头。
    【解决方案2】:

    感谢@chanibal,我找到了答案

    Input.GetMouseButtonDown(0)
    

    但我面临另一个问题,应用程序迷恋

    Gear VR 是否有任何自定义配置

    【讨论】:

    • 请注意,Input.GetMouseButtonDown(0) 不区分轻击和滑动。对于崩溃,您必须提供比这更多的信息(在单独的问题中执行此操作)。
    猜你喜欢
    • 1970-01-01
    • 2021-12-14
    • 1970-01-01
    • 2018-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-23
    • 2023-03-23
    相关资源
    最近更新 更多