Advertisement
Guest User

EditPath

a guest
Apr 25th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class EditPath: MonoBehaviour
  6. {
  7. public Color rayColor = Color.white;
  8. public List<Transform> path_objs = new List<Transform>();
  9. Transform[] theArray;
  10.  
  11. void OnDrawGizmos()
  12. {
  13. Gizmos.color = rayColor;
  14. theArray = GetComponentsInChildren<Transform>();
  15. path_objs.Clear();
  16.  
  17. foreach(Transform path_obj in theArray)
  18. {
  19. if(path_obj != this.transform)
  20. {
  21. path_objs.Add(path_obj);
  22. }
  23. }
  24.  
  25. for(int i = 0; i < path_objs.Count; i++)
  26. {
  27. Vector3 position = path_objs[i].position;
  28. if(i > 0)
  29. {
  30. Vector3 previous = path_objs[i - 1].position;
  31. Gizmos.DrawLine(previous, position);
  32. Gizmos.DrawWireSphere(position, 0.3f);
  33. }
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement