41 lines
806 B
C#
41 lines
806 B
C#
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Oculus.Platform.Samples.VrHoops
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|