using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
/*
this script goes on EACH hand anchor in oculus rift's cameraRig prefab.
then you checkmark isLeft bool in the editor for the leftHandANchor (this controls which half of the code below is used).
It checks every frame to see if the current control has had it's trigger pulled more than half way.
If so, it goes into the EventSystem and changes the "ray transform" to be this controller.
*/
public class toggleLaserPointer : MonoBehaviour {
public GameObject tabletControl; // EventSystem for UI. has the pointer we need to change out
public GameObject laser; //a dummy object with no collider. i just turn this on and off so you can see line from VR hands.
public bool isLeft = false; //flag for which hand is dominant. set in editor. determines which half of the code below is used.
// Update is called once per frame
void Update () {
if (isLeft)
{
if (OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger) > 0.5)
{
Debug.Log("pulled trigger");
tabletControl.GetComponent<OVRInputModule>().rayTransform = transform;
laser.SetActive(true);
}
else
{
laser.SetActive(false);
}
}
else {
if (OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger) > 0.5)
{
Debug.Log("pulled trigger");
tabletControl.GetComponent<OVRInputModule>().rayTransform = transform;
laser.SetActive(true);
}
else
{
laser.SetActive(false);
}
}
}
}