VR眼镜的触摸板移动控制
1.直接将脚本挂在需要移动的物体上
using UnityEngine;
using System.Collections;
using VRStandardAssets.Utils;
public class TouchPadMoveCtr : MonoBehaviour {
public VRInput _vrInput;
void OnEnable()
{
_vrInput.OnSwipe += OnSwipe;
}
void OnDisable()
{
_vrInput.OnSwipe -= OnSwipe;
}
// Update is called once per frame
void Update () {
}
void OnSwipe(VRInput.SwipeDirection swipeDirection)
{
if(swipeDirection != VRInput.SwipeDirection.NONE)
{
Debug.Log("Unity+OnSwipe"+swipeDirection);
if(swipeDirection == VRInput.SwipeDirection.RIGHT)
{
this.gameObject.transform.Translate(Vector3.forward);
}
if (swipeDirection == VRInput.SwipeDirection.LEFT)
{
this.gameObject.transform.Translate(Vector3.back);
}
if (swipeDirection == VRInput.SwipeDirection.UP)
{