unity3d - 检测悬停在 Oculus Quest (Unity3D) 上的按钮事件
问题描述
堆:
- Oculus Quest
- 统一2019.3
- Oculus VR 集成
- macOS 卡特琳娜
我有一个带有由画布(世界空间坐标)和两个按钮组成的 VR 界面的 Unity 场景。画布上附加了一个使用激光指示器的 OVR Raycaster 对象。总体来说效果很好,但是当我尝试拦截将激光指针悬停在按钮上产生的事件时,我只能得到点击事件。
我正在使用以下脚本(附加到按钮):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class VRButton : MonoBehaviour, IPointerEnterHandler, IPointerClickHandler, ISelectHandler
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void OnPointerEnter(PointerEventData eventData)
{
Debug.Log("Enter!");
transform.localScale *= 1.2f;
}
public void OnPointerExit(PointerEventData eventData)
{
Debug.Log("Exit!");
transform.localScale /= 1.2f;
}
public void OnPointerClick(PointerEventData eventData)
{
Debug.Log("Clicked!");
}
}
奇怪的是,当我用激光指向按钮并单击时,OnPointerEnter 和 OnPointerClick 都会被调用。只是悬停不会触发任何事件(也不会触发 OnPointerExit 或 OnPointerEnter)。
这是我的亚行日志:
03-15 22:59:53.085 13339 13355 I Unity : Clicked!
03-15 22:59:53.085 13339 13355 I Unity : UnityEngine.Logger:Log(LogType, Object)
03-15 22:59:53.085 13339 13355 I Unity : UnityEngine.EventSystems.EventFunction`1:Invoke(T1, BaseEventData)
03-15 22:59:53.085 13339 13355 I Unity : UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
03-15 22:59:53.085 13339 13355 I Unity : UnityEngine.EventSystems.OVRInputModule:ProcessMousePress(MouseButtonEventData)
03-15 22:59:53.085 13339 13355 I Unity : UnityEngine.EventSystems.OVRInputModule:ProcessMouseEvent(MouseState)
03-15 22:59:53.085 13339 13355 I Unity :
03-15 22:59:53.085 13339 13355 I Unity : (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
03-15 22:59:53.085 13339 13355 I Unity :
03-15 22:59:53.085 13339 13355 I Unity : Enter!
03-15 22:59:53.085 13339 13355 I Unity : UnityEngine.Logger:Log(LogType, Object)
03-15 22:59:53.085 13339 13355 I Unity : VRButton:OnPointerEnter(PointerEventData)
03-15 22:59:53.085 13339 13355 I Unity : UnityEngine.EventSystems.EventFunction`1:Invoke(T1, BaseEventData)
03-15 22:59:53.085 13339 13355 I Unity : UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
03-15 22:59:53.085 13339 13355 I Unity : UnityEngine.EventSystems.BaseInputModule:HandlePointerExitAndEnter(PointerEventData, GameObject)
03-15 22:59:53.085 13339 13355 I Unity : UnityEngine.EventSystems.OVRInputModule:ProcessMousePress(MouseButtonEventData)
03-15 22:59:53.085 13339 13355 I Unity : UnityEngine.EventSystems.OVRInputModule:ProcessMouseEvent(MouseState)
我该如何解决?
解决方案
推荐阅读
- python - 更优雅的递归迭代创建员工列表的方式
- json - Postgres 转换具有重复 ID 的 json
- angular - 无法将 Thrift 生成的 Typescript 导入 Angular 7 项目
- node.js - 无法在 Google Drive 上使用 googleapis 上传文件
- sikuli - 使用 Sikuli Finder() 搜索带有图标的屏幕截图,在循环中使用时提供类似缓存的响应
- android - 是否可以在不请求任何额外权限的情况下修改保存在缓存目录中的图像?
- r - 根据另一列的最大实例数对数据框进行子集
- html - 向右浮动将 div 推到页面末尾
- php - PHP 外部 IP
- python - 使用 cx_Oracle executemany() 从 Python 列表/字典批量插入到 Oracle 数据库