CheckPathTool.cs 989 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.Serialization;
  6. public class CheckPathTool : MonoBehaviour
  7. {
  8. public LineRenderer _LineRenderer;
  9. public List<GameObject> posList;
  10. public bool showPath;
  11. private void Awake()
  12. {
  13. _LineRenderer = this.GetComponent<LineRenderer>();
  14. _LineRenderer.enabled = false;
  15. }
  16. private void Start()
  17. {
  18. }
  19. private void OnDestroy()
  20. {
  21. }
  22. private void Update()
  23. {
  24. SetPath();
  25. }
  26. public void SetPathActive(bool flag)
  27. {
  28. showPath = false;
  29. _LineRenderer.enabled = flag;
  30. }
  31. public void SetPath()
  32. {
  33. Vector3[] tempPos = new Vector3[posList.Count];
  34. for (int i = 0; i < tempPos.Length; i++)
  35. {
  36. tempPos[i] = posList[i].transform.position;
  37. }
  38. _LineRenderer.positionCount = tempPos.Length;
  39. _LineRenderer.SetPositions(tempPos);
  40. }
  41. }