I am trying to be able to click on Objects on the PC screen while another user is in VR. It may just be that I need to set up another camera for the asynchronous player but I have not found any info on that yet.
I have tried multiple versions of raycast hit such as:
public UnityEvent mouseClickEvent;
private GameObject button;
private void Start()
{
button = this.gameObject;
}
private void Update()
{
if (Input.GetMouseButtonDown(0))
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, 100.0f) && hit.collider.gameObject == button)
{
if (hit.transform != null)
//mouseClickEvent.Invoke();
CurrentClickedGameObject(hit.transform.gameObject);
}
}
}
public void CurrentClickedGameObject(GameObject gameObject)
{
if (gameObject.tag == "button")
{
mouseClickEvent.Invoke();
}
}
And I have tried GetMouseButtonDown:
void OnMouseOver()
{
if (Input.GetMouseButtonDown(0))
{
mouseClickEvent.Invoke();
}
}
Playing with the camera Physics Raycaster, the objects layer, tag, rigibody collider type and more has all ben fruitless. Any help would be greatly appreciated.