Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

44 lines
981 B

namespace Oculus.Platform.Samples.VrVoiceChat
{
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
// Helper class to attach to the main camera that raycasts where the
// user is looking to select/deselect Buttons.
public class VREyeRaycaster : MonoBehaviour
{
[SerializeField] private UnityEngine.EventSystems.EventSystem m_eventSystem = null;
private Button m_currentButton;
void Update ()
{
RaycastHit hit;
Button button = null;
// do a forward raycast to see if we hit a Button
if (Physics.Raycast(transform.position, transform.forward, out hit, 50f))
{
button = hit.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);
}
}
}
}
}