1

堆:

  • 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)

我该如何解决?

4

0 回答 0