Advertisement
kadyr

Untitled

Oct 5th, 2021
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5.  
  6. public class LinePlacer : MonoBehaviour //dont forget to add to namespace
  7. {
  8. [Serializable]
  9. public struct NeedFill
  10. {
  11. public Vector3 startPosition;
  12. public Vector3 endPosition;
  13. }
  14.  
  15. public NeedFill[] positions;
  16.  
  17. [SerializeField]
  18. private LineRenderer lineObject;
  19.  
  20. private Transform firstLine;
  21.  
  22. private void CreateLine()
  23. {
  24. for (int i = 0; i < positions.Length; i++)
  25. {
  26. var t = Instantiate(lineObject);
  27. t.SetPosition(0, positions[i].startPosition);
  28. t.SetPosition(1, positions[i].endPosition);
  29. if (i == 0)
  30. firstLine = t.transform;
  31. else
  32. t.transform.parent = firstLine;
  33. }
  34.  
  35. firstLine = null;
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement