Hi everyone,
Im having a hard time modifying this gvrreticle script. I want the reticle to disappear when I’m not looking at an interactable object. I made a script called interactable, with a public bool called isInteractable. Now this is what I’ve done in the gvrreticle script:
/// Called when the user is looking on a valid GameObject. This can be a 3D
/// or UI element.
///
/// The camera is the event camera, the target is the object
/// the user is looking at, and the intersectionPosition is the intersection
/// point of the ray sent from the camera on the object.
public void OnGazeStart(Camera camera, GameObject targetObject, Vector3 intersectionPosition,
bool isInteractive) {
SetGazeTarget(intersectionPosition, isInteractive);
var interactableObject = targetObject.GetComponent<Interactable> ();
if(interactableObject.isInteractable){
rend.enabled = true;
} else {
rend.enabled = false;
}
}
/// Called every frame the user is still looking at a valid GameObject. This
/// can be a 3D or UI element.
///
/// The camera is the event camera, the target is the object the user is
/// looking at, and the intersectionPosition is the intersection point of the
/// ray sent from the camera on the object.
public void OnGazeStay(Camera camera, GameObject targetObject, Vector3 intersectionPosition,
bool isInteractive) {
SetGazeTarget(intersectionPosition, isInteractive);
var interactableObject = targetObject.GetComponent<Interactable> ();
if(interactableObject.isInteractable){
rend.enabled = true;
} else {
rend.enabled = false;
}
}
/// Called when the user's look no longer intersects an object previously
/// intersected with a ray projected from the camera.
/// This is also called just before **OnGazeDisabled** and may have have any of
/// the values set as **null**.
///
/// The camera is the event camera and the target is the object the user
/// previously looked at.
public void OnGazeExit(Camera camera, GameObject targetObject) {
rend.enabled = false;
reticleDistanceInMeters = kReticleDistanceMax;
reticleInnerAngle = kReticleMinInnerAngle;
reticleOuterAngle = kReticleMinOuterAngle;
}