我在 LineRenderer SetWidth 上收到警告,它已过时,我应该如何修复它?

I'm getting warning on LineRenderer SetWidth that it's obsolete how should i fix it?

lineRenderer.SetWidth(startWidth, endWidth);
lineRenderer.SetVertexCount(linePoints.Count);

在两行相同的警告:

'LineRenderer.SetVertexCount(int)' 已过时:'SetVertexCount has been deprecated. Please use the numPositions property instead.'

'LineRenderer.SetWidth(float, float)' 已过时:'SetWidth has been deprecated. Please use the startWidth, endWidth, or widthCurve properties instead.'

我当时试过这个:

lineRenderer.startWidth(startWidth, endWidth);

但随后在 startWidth 上出现错误 属性:

'LineRenderer.startWidth'不能像方法一样使用。

某些 LineRenderer 函数已更改为属性,并且还重命名以避免混淆。您设置属性而不是将其作为函数调用。对于 lineRenderer.SetVertexCount,您可以使用 lineRenderer.positionCount 来设置它。

lineRenderer.startWidth = startWidth;
lineRenderer.endWidth = endWidth;
lineRenderer.positionCount = linePoints.Count;

按照编译器的建议执行即可。

即:

lineRenderer.startWidth = startWidth;
lineRenderer.endWidth = endWidth;
lineRenderer.positionCount = linePoints.Count;