public DiscreteCurve ConvertToDCurve() { float segLength = 0.1f; List <Vector3> discretePoints = discretizeSpline(segLength); lineRender.SetVertexCount(discretePoints.Count); lineRender.SetPositions(discretePoints.ToArray()); GameObject discretized = new GameObject(); discretized.transform.parent = transform.parent; discretized.name = "DiscretizedCurve" + DiscreteCurve.NextCurveNumber(); DiscreteCurve dCurve = discretized.AddComponent <DiscreteCurve>(); dCurve.InitFromPoints(discretePoints, segLength); LineRenderer lr = dCurve.GetComponent <LineRenderer>(); lr.SetWidth(0.1f, 0.1f); lr.material = lineRender.material; gameObject.SetActive(false); return(dCurve); }
DiscreteCurve ToDiscreteCurve() { DiscreteCurve[] old = FindObjectsOfType <DiscreteCurve>(); foreach (DiscreteCurve curve in old) { Destroy(curve.gameObject); } GameObject obj = new GameObject(); obj.name = "ImpulseDCurve"; DiscreteCurve dc = obj.AddComponent <DiscreteCurve>(); dc.InitFromPoints(displayPoints, 0.1f); LineRenderer lr = dc.GetComponent <LineRenderer>(); lr.SetWidth(0.1f, 0.1f); lr.material = lRenderer.material; lr.SetColors(Color.white, Color.white); Destroy(gameObject); return(dc); }