Line Renderer (线渲染器):
通过鼠标或者手指在屏幕中画线:
1.声明,判断点击。
[SerializeField]
private LineRenderer lineRenderer;
private bool firstMouseDown=false;//第一次点击
private bool mouseDown=false; //一直点击
private void Update()
{
if (Input.GetMouseButtonDown(0)) {
firstMouseDown = true;
mouseDown = true;
}
if (Input.GetMouseButtonUp(0)) {
mouseDown = false;
}
OnDrawLine(); //调用画线方法
firstMouseDown = false;
}
2. 画线
private Vector3[] positions &