Advertisement
kadyr

Untitled

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