Line.cs 634 B

123456789101112131415161718192021222324252627282930
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Line : MonoBehaviour {
  5. private LineRenderer line;
  6. public GameObject pos1;
  7. public GameObject pos2;
  8. // Use this for initialization
  9. void Start () {
  10. line = this.gameObject.AddComponent<LineRenderer>();
  11. line.material = new Material(Shader.Find("Standard"));
  12. line.SetVertexCount(2);
  13. line.SetColors(Color.yellow, Color.yellow);
  14. line.SetWidth(0.01f, 0.01f);
  15. }
  16. // Update is called once per frame
  17. void Update () {
  18. line.SetPosition(0, pos1.transform.position);
  19. line.SetPosition(1, pos2.transform.position);
  20. }
  21. }