using System.Collections;
using System.Collections.Generic;
using Microsoft.MixedReality.Toolkit.Input;
using UnityEngine;
using UnityEngine.XR.WSA.Input;
using UnityEngine.EventSystems;
using System;
public class test : MonoBehaviour, IMixedRealityPointerHandler, IMixedRealityFocusHandler
{
GestureRecognizer gestureRecognizer;
GameObject hitObj; //视线中检测到的物体
void Start()
{
gestureRecognizer = new GestureRecognizer();
gestureRecognizer.HoldStarted += test2;
gestureRecognizer.Tapped += test3;
gestureRecognizer.StartCapturingGestures();
}
//检测到手机点下然后停留的时候触发
void test2(HoldStartedEventArgs action )
{
Debug.Log("HoldStartedEventArgs");
}
//检测到手指点击的时候触发
void test3(TappedEventArgs action)
{
Debug.Log("TappedEventArgs");
}
//以下需检测到物体才能触发
//视野中的中心点进入UI
void IMixedRealityFocusHandler.OnFocusEnter(FocusEventData eventData)
{
//Debug.Log("OnFocusEnter");
}
//视野中的中心点离开UI
void IMixedRealityFocusHandler.OnFocusExit(FocusEventData eventData)
{
//Debug.Log("OnFocusExit");
}
//手指点击UI
void IMixedRealityPointerHandler.OnPointerClicked(MixedRealityPointerEventData eventData)
{
Debug.Log("OnPointerClicked");
}
//手指按下UI
void IMixedRealityPointerHandler.OnPointerDown(MixedRealityPointerEventData eventData)
{
//Debug.Log("OnPointerDown");
}
//手指长按UI
void IMixedRealityPointerHandler.OnPointerDragged(MixedRealityPointerEventData eventData)
{
//Debug.Log("OnPointerDragged");
}
//手指抬起UI
void IMixedRealityPointerHandler.OnPointerUp(MixedRealityPointerEventData eventData)
{
//Debug.Log("OnPointerUp");
}
void Update()
{
hitObj = Camera.main.GetComponent<GazeProvider>().GazeTarget;
if (hitObj)
{
Debug.Log("输出检测到的物体 " + hitObj.name);
}
}
}
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- shangjiatang.cn 版权所有 湘ICP备2022005869号-4
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务