【问题标题】:I'm getting warning on LineRenderer SetWidth that it's obsolete how should i fix it?我在 LineRenderer SetWidth 上收到警告说它已经过时了我应该如何修复它?
【发布时间】:2017-06-08 17:59:05
【问题描述】:
lineRenderer.SetWidth(startWidth, endWidth);
lineRenderer.SetVertexCount(linePoints.Count);

在两行相同的警告:

'LineRenderer.SetVertexCount(int)' 已过时:'SetVertexCount 已被弃用。请改用 numPositions 属性。

'LineRenderer.SetWidth(float, float)' 已过时:'SetWidth 已被弃用。请改用 startWidth、endWidth 或 widthCurve 属性。

然后我试过了:

lineRenderer.startWidth(startWidth, endWidth);

但是在 startWidth 属性上出现错误:

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

【问题讨论】:

标签: c# unity3d unity5


【解决方案1】:

一些LineRenderer 函数已更改为属性并重命名以避免混淆。您设置属性不将其作为函数调用。对于lineRenderer.SetVertexCount,您使用lineRenderer.positionCount 进行设置。

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

【讨论】:

    【解决方案2】:

    按照编译器的建议去做。

    IE:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-16
      • 2017-03-09
      • 1970-01-01
      • 1970-01-01
      • 2018-04-16
      • 2011-07-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多