using System.Collections; using System.Collections.Generic; using UnityEngine; public class LineEffect : MonoBehaviour { public LineRenderer line; private Vector2 Interval = new Vector2(0.05f, 0); private Vector2 offset; // Start is called before the first frame update void Start() { line = this.gameObject.GetComponent(); StartCoroutine(onDGTween()); } IEnumerator onDGTween() { while (true) { yield return new WaitForSeconds(0.04f); if (line != null) { offset -= Interval; line.materials[0].SetTextureOffset("_MainTex", offset); if (offset.x <= -1) { offset = Vector2.zero; } } } } }