2022-08-16 23:22:52 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.XR.Interaction.Toolkit;
|
|
|
|
|
|
|
|
public class RayManager : MonoBehaviour
|
|
|
|
{
|
|
|
|
public bool RaySwitch = true;
|
2022-08-27 00:04:14 +02:00
|
|
|
public float Distance = 0.4f;
|
2022-08-16 23:22:52 +02:00
|
|
|
XRRayInteractor interactor;
|
|
|
|
XRInteractorLineVisual lineVisual;
|
|
|
|
LineRenderer lineRenderer;
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
interactor = GetComponent<XRRayInteractor>();
|
|
|
|
lineVisual = GetComponent<XRInteractorLineVisual>();
|
|
|
|
lineRenderer = lineVisual.GetComponent<LineRenderer>();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
2022-08-19 00:08:42 +02:00
|
|
|
if (gameObject.transform.position.z > Distance || !RaySwitch)
|
2022-08-16 23:22:52 +02:00
|
|
|
{
|
|
|
|
interactor.enabled = false;
|
|
|
|
lineRenderer.enabled = false;
|
|
|
|
lineVisual.enabled = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
interactor.enabled = true;
|
|
|
|
lineRenderer.enabled = true;
|
|
|
|
lineVisual.enabled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|