改脚本挂在摄像机上
using System.Collections;
using System.Collections.Generic; using UnityEngine; using UnityEngine.VR.WSA.Input; public class GestureManagerrr : MonoBehaviour { GestureRecognizer gesture; // Use this for initialization void Start () { gesture = new GestureRecognizer(); gesture.TappedEvent += Gesture_TappedEvent;//手势点击 gesture.StartCapturingGestures();//开启手势捕捉 } private void Gesture_TappedEvent(InteractionSourceKind source, int tapCount, Ray headRay) { FindObjectOfType<Cbuerrr>().OnTapped(); }}
此脚本挂在Cube上
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Cbuerrr : MonoBehaviour { public void OnTapped() { gameObject.SetActive(false); } }
