mirror of
https://udrimavric.com/MAVRIC/Stratasys-450mc-VR.git
synced 2025-01-23 07:38:33 -05:00
40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using UnityEngine;
|
|
|
|
namespace Part_Labels
|
|
{
|
|
public class PartLabel : MonoBehaviour
|
|
{
|
|
[SerializeField] private GameObject targetPart;
|
|
[SerializeField] private Vector3 canvasLineOffset = new Vector3(0, -0.04f, 0);
|
|
[SerializeField] private LineRenderer lineRenderer;
|
|
[SerializeField] private Canvas canvas;
|
|
|
|
private void Start()
|
|
{
|
|
Deactivate();
|
|
}
|
|
|
|
[ExecuteAlways]
|
|
public void Activate()
|
|
{
|
|
lineRenderer.gameObject.SetActive(true);
|
|
lineRenderer.enabled = true;
|
|
canvas.gameObject.SetActive(true);
|
|
Vector3 targetPos = targetPart.transform.position;
|
|
|
|
Vector3[] positions = new Vector3[2];
|
|
positions[0] = canvas.transform.position+canvasLineOffset;
|
|
positions[1] = targetPos;
|
|
lineRenderer.SetPositions(positions);
|
|
}
|
|
|
|
[ExecuteAlways]
|
|
public void Deactivate()
|
|
{
|
|
canvas.gameObject.SetActive(false);
|
|
lineRenderer.gameObject.SetActive(false);
|
|
}
|
|
|
|
}
|
|
}
|