DrawLinkLine.cs 1011 B

123456789101112131415161718192021222324252627282930313233
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class DrawLinkLine : MonoBehaviour
  5. {
  6. public LineRenderer LineRenderer;
  7. public float lineWidth = 0.002f;
  8. public Transform startpoint;
  9. public Transform endpoint;
  10. // Start is called before the first frame update
  11. void Start()
  12. {
  13. }
  14. // Update is called once per frame
  15. void Update()
  16. {
  17. //是否使用世界坐标
  18. LineRenderer.useWorldSpace = true;
  19. //设置开始和结束位置0代表第一个点,1代表第二个点
  20. LineRenderer.SetPosition(0, startpoint.position);
  21. LineRenderer.SetPosition(1, endpoint.position);
  22. //开始和结束位置的颜色
  23. //LineRenderer.startColor = new Color(1, 0.8F, 0.1F, 0);
  24. //LineRenderer.endColor = Color.red;
  25. //开始和结束粗细大小
  26. LineRenderer.startWidth = lineWidth;
  27. LineRenderer.endWidth = lineWidth;
  28. }
  29. }