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

ぃ、小莉子 提交于 2020-01-07 03:50:20

问题


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

On both lines same warning:

'LineRenderer.SetVertexCount(int)' is obsolete: 'SetVertexCount has been deprecated. Please use the numPositions property instead.'

And

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

I tried this then:

lineRenderer.startWidth(startWidth, endWidth);

But then getting error on startWidth property:

'LineRenderer.startWidth' cannot be used like a method.


回答1:


Some of the LineRenderer functions has been changed to properties and also renamed to avoid confusion. You set properties not call it as a function. For lineRenderer.SetVertexCount, you use lineRenderer.positionCount to set that.

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



回答2:


Just do what the compiler is suggesting.

I.E.:

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


来源:https://stackoverflow.com/questions/44442631/im-getting-warning-on-linerenderer-setwidth-that-its-obsolete-how-should-i-fix

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!