Example #1
0
 public void RemoveLastAddedSegment()
 {
     if (activeSegment != null)
     {
         Destroy(activeSegment.gameObject);
     }
     activeSegment = oldSegments.Pop <StretchyThing>();
 }
Example #2
0
 public void AddSegment(Vector3 from, Vector3 to, Vector3 scale)
 {
     // lastAddedSegment is now old and will be replaced with new segment
     if (activeSegment != null)
     {
         oldSegments.Add(activeSegment);
     }
     activeSegment = createNewLineSegement(scale);
     activeSegment.Stretch(from, to);
     activeSegment.transform.parent = transform;
 }
Example #3
0
//--------------------------------------------------------------------------HELPERS:

    private StretchyThing createNewLineSegement(Vector3 scale)
    {
        GameObject newLine = Instantiate(LinePrefab);

        newLine.transform.localScale = scale;
        StretchyThing newLineStretchyThing = newLine.GetComponent <StretchyThing>();

        if (newLineStretchyThing != null)
        {
            return(newLineStretchyThing);
        }
        return(newLine.AddComponent <StretchyThing>());
    }
Example #4
0
 public void Clear()
 {
     if (oldSegments != null)
     {
         foreach (StretchyThing segment in oldSegments)
         {
             GameObject.Destroy(segment.gameObject);
         }
     }
     if (activeSegment != null)
     {
         GameObject.Destroy(activeSegment.gameObject);
     }
     oldSegments   = new List <StretchyThing>();
     activeSegment = null;
 }