37 lines
834 B
C#
37 lines
834 B
C#
using UnityEngine;
|
|
/// <summary>
|
|
/// 生成地线
|
|
/// </summary>
|
|
public class DrawGroundLine : MonoBehaviour
|
|
{
|
|
private LineRenderer line;
|
|
/// <summary>
|
|
/// 地线端点
|
|
/// </summary>
|
|
public Transform left, right;
|
|
public Material material;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
Draw();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
line.SetPosition(0, left.position);
|
|
line.SetPosition(1, right.position);
|
|
}
|
|
public void Draw()
|
|
{
|
|
line = gameObject.AddComponent<LineRenderer>();
|
|
line.material = material;
|
|
line.material.color = Color.white;
|
|
line.positionCount = 2;
|
|
//line.SetWidth(0.005f, 0.005f);
|
|
line.startWidth = 0.005f;
|
|
line.endWidth = 0.005f;
|
|
|
|
}
|
|
}
|