[英]How can I use linerenderer.startColor and linerenderer.startWidth?
void DrawLine(Vector3 start, Vector3 end, Color color, float duration = 0.2f)
{
GameObject myLine = new GameObject();
myLine.transform.position = start;
myLine.AddComponent<LineRenderer>();
LineRenderer lr = myLine.GetComponent<LineRenderer>();
lr.material = new Material(Shader.Find("Particles/Alpha Blended Premultiply"));
lr.SetColors(color, color);
lr.SetWidth(0.1f, 0.1f);
lr.SetPosition(0, start);
lr.SetPosition(1, end);
GameObject.Destroy(myLine, duration);
}
在这两行中,我收到警告:
lr.SetColors(color, color);
lr.SetWidth(0.1f, 0.1f);
第一行:
'LineRenderer.SetColors(Color,Color)'已过时:'请改用startColor,endColor或colorGradient。
第二行:
'LineRenderer.SetWidth(float,float)'已过时:'改为使用startWidth,endWidth或widthCurve。
在统一文档中找不到如何通过脚本使用它。
实际上并不难使用...
lr.startColor = color;
lr.endColor = color;
lr.startWidth = 0.1f;
lr.endWidth = 0.1f;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.