using UnityEngine;
using System.Collections;
public class WS_Line : MonoBehaviour {
public Transform target;
public GameObject obj;
// Update is called once per frame
void Update()
{
DrawLine();
}
void DrawLine()
{
this.GetComponent<LineRenderer>().SetVertexCount(2);
this.GetComponent<LineRenderer>().SetPosition(0, obj.transform.position);
this.GetComponent<LineRenderer>().SetPosition(1, target.position);x
}
}
前2个变量是线的起点或者终点,然后在绑定脚本的这个物体上创建一个LineRenderer就可以了。