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);
}
On this two lines I'm getting warnings:
lr.SetColors(color, color);
lr.SetWidth(0.1f, 0.1f);
The first line:
'LineRenderer.SetColors(Color, Color)' is obsolete: 'Use startColor, endColor or colorGradient instead.
Second line:
'LineRenderer.SetWidth(float, float)' is obsolete: 'Use startWidth, endWidth or widthCurve instead.'
I couldn't find how to use it by script in the unity documentation.
Not actually that hard to use...
lr.startColor = color;
lr.endColor = color;
lr.startWidth = 0.1f;
lr.endWidth = 0.1f;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.