StationObscurum/Assets/Scripts/DynamicLine.cs

27 lines
619 B
C#
Raw Normal View History

2023-03-28 00:49:30 +02:00
using UnityEngine;
[ExecuteAlways]
[RequireComponent(typeof(LineRenderer))]
public class DynamicLine : MonoBehaviour
{
2023-06-01 17:03:48 +02:00
[SerializeField] private float length = 5f;
[SerializeField] private int count = 2;
2023-03-28 00:49:30 +02:00
private LineRenderer lineRenderer;
2023-06-01 17:03:48 +02:00
private int pCount;
private float pLength;
2023-03-28 00:49:30 +02:00
// Start is called before the first frame update
2023-06-01 17:03:48 +02:00
private void Start()
2023-03-28 00:49:30 +02:00
{
2023-06-01 17:03:48 +02:00
lineRenderer = GetComponent<LineRenderer>();
2023-03-28 00:49:30 +02:00
}
// Update is called once per frame
2023-06-01 17:03:48 +02:00
private void FixedUpdate()
2023-03-28 00:49:30 +02:00
{
2023-06-01 17:03:48 +02:00
if (pLength != length || pCount != count) lineRenderer.positionCount = count;
2023-03-28 00:49:30 +02:00
}
2023-06-01 17:03:48 +02:00
}