public void ResetObject() { if (roadCreator == null) { roadCreator = (RoadCreator)target; } for (int i = roadCreator.transform.GetChild(0).childCount - 1; i >= 0; i--) { Undo.DestroyObjectImmediate(roadCreator.transform.GetChild(0).GetChild(i).gameObject); } roadCreator.startIntersection = null; roadCreator.endIntersection = null; roadCreator.startIntersectionConnection = null; roadCreator.endIntersectionConnection = null; roadCreator.RemoveLaneMarkings(); }