using System.Collections; using System.Collections.Generic; using UnityEngine; [ExecuteAlways] [RequireComponent(typeof(LineRenderer))] public class DynamicLine : MonoBehaviour { [SerializeField] private float length = 5f; [SerializeField] private int count = 2; private float pLength; private int pCount; private LineRenderer lineRenderer; // Start is called before the first frame update void Start() { lineRenderer= GetComponent(); } // Update is called once per frame void FixedUpdate() { if (pLength != length||pCount!=count) { lineRenderer.positionCount = count; } } }