简体   繁体   English

在Unity中使用gearVR上的触摸板

[英]Utilizing the touchpad on gearVR in Unity

Still learning here and starting of with basics (just a plain Plane and moving as the first person around) However i can run the app and look around and up and down etc. but can;t make the camera move when touching the touchpad on the GearVR headset. 仍然在这里学习和开始基础知识(只是一个普通的平面,并作为第一个人移动)但是我可以运行应用程序,环顾四周,上下等但可以;当触摸触摸板时,使相机移动GearVR耳机。

I have created the script (c#) and attached to the camera in unity: 我已创建脚本(c#)并以统一方式连接到相机:

using UnityEngine;
using System.Collections;

public class Moving : MonoBehaviour {

// Use this for initialization
void Start()
{
    if (Input.GetButton("Tap"))
    {
        // Do something if tap starts
    }

    if (Input.GetButtonUp("Tap"))
    {
        // Do something if tap ends

    }
}

    // Update is called once per frame
    void Update () {
    if (Input.GetButton("Tap"))
    {
        // Do something if tap starts
    }

    if (Input.GetButtonUp("Tap"))
    {
        // Do something if tap ends
    }

}
}

But it still doesn't seem to work. 但它似乎仍然没有用。 When i build and run the app it does nothing :-( 当我构建并运行应用程序时它什么都不做:-(

I know i am doing something wrong but not sure what. 我知道我做错了什么但不确定是什么。

Handling Single Tap in Oculus Gear VR: 在Oculus Gear VR中处理单击:

void Start()
{
    OVRTouchpad.Create();
    OVRTouchpad.TouchHandler += OVRTouchpad_TouchHandler;
}


void OVRTouchpad_TouchHandler (object sender, System.EventArgs e)
{
    OVRTouchpad.TouchArgs touchArgs = (OVRTouchpad.TouchArgs)e;
    OVRTouchpad.TouchEvent touchEvent = touchArgs.TouchType;
    if(touchArgs.TouchType == OVRTouchpad.TouchEvent.SingleTap)
    {
        // Your response to Tap goes here.
    }
}

Tap and Hold to Move: 点击并按住移动:

  1. You need to register Tap key in your input following this tutorial. 您需要在本教程后面的输入中注册Tap
  2. Add OVRPlayerController prefab to move around the scene. 添加OVRPlayerController预制件以在场景中移动。 This will let you move using keyboard W/A/S/D keys in Unity Editor. 这将允许您使用Unity Editor中的键盘W / A / S / D键移动。
  3. Next you need to integrate Tap key with OVR Player controller script to move in forward direction. 接下来,您需要将Tap键与OVR Player控制器脚本集成以向前移动。

here are some useful links: 这里有一些有用的链接:

http://forum.unity3d.com/threads/gear-vr-touchpad-fps-script.373103/ http://forum.unity3d.com/threads/gear-vr-touchpad-fps-script.373103/

http://rifty-business.blogspot.co.uk/2014/04/unity-pro-4-using-ovrcameracontroller.html http://rifty-business.blogspot.co.uk/2014/04/unity-pro-4-using-ovrcameracontroller.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM