LineEffect.cs 842 B

123456789101112131415161718192021222324252627282930313233
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class LineEffect : MonoBehaviour
  5. {
  6. public LineRenderer line;
  7. private Vector2 Interval = new Vector2(0.05f, 0);
  8. private Vector2 offset;
  9. // Start is called before the first frame update
  10. void Start()
  11. {
  12. line = this.gameObject.GetComponent<LineRenderer>();
  13. StartCoroutine(onDGTween());
  14. }
  15. IEnumerator onDGTween()
  16. {
  17. while (true)
  18. {
  19. yield return new WaitForSeconds(0.04f);
  20. if (line != null)
  21. {
  22. offset -= Interval;
  23. line.materials[0].SetTextureOffset("_MainTex", offset);
  24. if (offset.x <= -1)
  25. {
  26. offset = Vector2.zero;
  27. }
  28. }
  29. }
  30. }
  31. }