Unity 折线

如果配合UI做渲染,那么需要把canvas改为 scree space - camera 类型,否则在ui上的linerenderer无法和ui融合

LineRenderer line;

line = gameObject.AddComponent();
line.startColor = Color.white;
line.endColor = Color.yellow;
line.startWidth = 30f;
line.endWidth = 0f;
line.useWorldSpace = false;
addPot(new Vector3());
addPot(to_target.transform.position-transform.position);

void addPot(Vector3 pot){
        pots.Add(pot);
        line.positionCount++;
        line.SetPosition(line.positionCount-1,pot);
}

你可能感兴趣的:(Unity 折线)