Files
2026-02-21 16:45:37 +08:00

41 lines
810 B
C#

using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Oculus.Platform.Samples.VrVoiceChat
{
public class VREyeRaycaster : MonoBehaviour
{
[SerializeField]
private EventSystem m_eventSystem;
private Button m_currentButton;
private void Update()
{
Button button = null;
RaycastHit hitInfo;
if (Physics.Raycast(base.transform.position, base.transform.forward, out hitInfo, 50f))
{
button = hitInfo.collider.GetComponent<Button>();
}
if (button != null)
{
if (m_currentButton != button)
{
m_currentButton = button;
m_currentButton.Select();
}
}
else if (m_currentButton != null)
{
m_currentButton = null;
if (m_eventSystem != null)
{
m_eventSystem.SetSelectedGameObject(null);
}
}
}
}
}