参考:https://www.xuanyusong.com/archives/561
可用于场景内变化的坐标数据的测试(浮空地块顶点数据一直在变 )
1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 5 public class TestLineRender : MonoBehaviour { 6 private Vector3 v0 = new Vector3(1.0f, 0.0f, 0.0f); 7 private Vector3 v1 = new Vector3(0.0f, 1.0f, 0.0f); 8 private Vector3 v2 = new Vector3(0.0f, 0.0f, 1.0f); 9 10 private LineRenderer lineRender = null; 11 12 // Use this for initialization 13 void Start () 14 { 15 lineRender = gameObject.AddComponent<LineRenderer>(); 16 lineRender.material = new Material(Shader.Find("Sprites/Default")); 17 lineRender.startColor = Color.blue; 18 lineRender.endColor = Color.blue; 19 lineRender.startWidth = 0.01f; 20 lineRender.endWidth = 0.01f; 21 lineRender.useWorldSpace = true; 22 lineRender.positionCount = 4; 23 } 24 25 // Update is called once per frame 26 void Update () 27 { 28 lineRender.SetPosition(0, v0); 29 lineRender.SetPosition(1, v1); 30 lineRender.SetPosition(2, v2); 31 lineRender.SetPosition(3, v0); 32 } 33 }