I have the following code in Unity3D for adding and deleting a line segment for a 3D drawing:
public class LinearPiecewiseTrajectory : MonoBehaviuor
{
private List<LineSegment> lineSegmentRep;
//other stuff here
public void addSegment()
{
GameObject lineSegmentObject = new GameObject();
lineSegmentObject.name = "LineSegment";
LineSegment lineSegment = lineSegmentObject.AddComponent<LineSegment>();
lineSegmentObject.transform.parent = this.transform;
lineSegmentRep.Add(lineSegment);
}
}
public void deleteSegment(int i)
{
Destroy(lineSegmentRep[i]);
}
LineSegment is a MonoBehavior I have defined.
However, this destroy call isn't actually destroying the LineSegment object. The only discernible behavior I can find is that it's setting the old LineSegment's geometric transform back to identity.
What am I missing?