美文网首页
HTCVIVE 开发

HTCVIVE 开发

作者: 玄策丶 | 来源:发表于2019-12-23 11:58 被阅读0次

1、

using HTC.UnityPlugin.Vive;
using UnityEngine;
using UnityEngine.EventSystems;
using System;
using System.Collections.Generic;
using System.Collections;

public class ShowShenFenInfo : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
{
    private HashSet<PointerEventData> hovers = new HashSet<PointerEventData>();
    public void OnPointerEnter(PointerEventData eventData) 
   {
        if (hovers.Add(eventData) && hovers.Count ==1) 
        {
            Debug.Log("jinru");   
        }
    }
    public void OnPointerExit(PointerEventData eventData)
    {
        if (hovers.Remove(eventData) && hovers.Count == 0)
        {
            Debug.Log("likai");
        }
    }
    public void OnPointerClick(PointerEventData eventData) {
        var viveEventData = eventData as VivePointerEventData;
        if (viveEventData != null) 
        {
            if (viveEventData.viveButton == ControllerButton.Pad)
            {
                Debug.Log("Pad");
            }
        } 
        else if (eventData != null) 
         {
            if (eventData.button == PointerEventData.InputButton.Left) 
            {
                Debug.Log("左键");
            }
        }
    }
}

相关文章

网友评论

      本文标题:HTCVIVE 开发

      本文链接:https://www.haomeiwen.com/subject/esjznctx.html