我有一个 LineRenderer 路径来展示高尔夫球的轨迹。请参考图片中的褐色路径。
private void createTrail()
{
lineRenderer.SetColors(tracerColor, tracerColor);
lineRenderer.SetVertexCount(maxVertexCount);
for (int idx = 0; idx < (maxVertexCount - 2); idx++)
{//Add another vertex to show ball's roll
lineRenderer.SetPosition(idx, new Vector3((float)pts[idx * (int)positionSampling].z, (float)pts[idx * (int)positionSampling].y, (float)pts[idx * (int)positionSampling].x));
}
lineRenderer.SetPosition(maxVertexCount - 2, new Vector3((float)pts[goal - 1].z, (float)pts[goal - 1].y, (float)pts[goal - 1].x));
lineRenderer.SetPosition(maxVertexCount - 1, transform.position);
}
路径是使用pts[]数组
中的点绘制的。
在重复显示时,我需要清除旧路径以重新绘制相同的路径。如何清除旧路径?