AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
ConnectorBehaviour.cs
Go to the documentation of this file.
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 
8 public class ConnectorBehaviour : MonoBehaviour {
9 
10  [SerializeField]
11  private GameObject widget;
12 
13  [SerializeField]
14  private GameObject rootNode;
15 
16  #region PRIVATE_MEMBER_VARIABLES
17  private Vector3 root;
18  private Vector3 widgetPos;
19 
20  private LineRenderer line;
21  #endregion //PRIVATE MEMBER VARIABLES
22 
23  #region UNITY_MONOBEHAVIOUS_METHODS
24  // Use this for initialization
25  void Start () {
26  root = rootNode.transform.position;
27  widgetPos = widget.transform.position;
28  line = gameObject.GetComponent<LineRenderer>();
29 
30  line.SetPosition(0, root);
31  line.SetPosition(1, widgetPos);
32  }
33 
34 
35  // Update is called once per frame
36  void Update () {
37  root = rootNode.transform.position;
38  widgetPos = widget.transform.position;
39  line.SetPosition(0, root);
40  line.SetPosition(1, widgetPos);
41  }
42  #endregion //UNITY MONOBEHAVIOR METHODS
43 }
Draws a line from the widget to the rootnode, updating as widget position changes ...