AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
WidgetHandler.cs
Go to the documentation of this file.
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 using UnityEngine.UI;
5 namespace ARDesign
6 {
7  namespace Widgets
8  {
13  public abstract class WidgetType<T> : WidgetHandler where T : InfluxReader
14  {
15 
19  protected T reader;
20 
21  #region UNITY_MONOBEHAVIOUR_METHODS
22  void Awake()
23  {
24  reader = this.GetComponent<T>();
26  }
27  #endregion //UNITY_MONOBEHAVIOUR_METHODS
28  }
29 
33  public abstract class WidgetHandler : MonoBehaviour
34  {
35  #region PRIVATE_MEMBER_VARIABLES
36  protected bool isEnable = false;
37 
38  [SerializeField]
39  protected GameObject WidgetObj;
40  [SerializeField]
41  protected GameObject Connector;
42 
44  #endregion //PRIVATE_MEMBER_VARIABLES
45 
46  #region PUBLIC_METHODS
47  public virtual void EnableWidget(bool enable)
52  {
53  Connector.SetActive(enable);
54  WidgetObj.SetActive(enable);
55  isEnable = !isEnable;
56  }
57 
62  public void SetWidgetObjDistance(float dist)
63  {
64  Vector3 oldPos = WidgetObj.transform.localPosition;
65  WidgetObj.transform.localPosition = new Vector3(oldPos.x, oldPos.y, dist);
66  }
67  #endregion //PUBLIC_METHODS
68  }
69  }
70 }
T reader
Reader indicates the data loading functions of the widget. Should derive from InfluxReader ...
void SetWidgetObjDistance(float dist)
Sets distance from object to root node
Typed widget handler class. Type indicates form of Widget content and should derive from InfluxReader...
Abstract class for querying Influx data to widgets. Includes implemented methods for building useful ...
Definition: InfluxReader.cs:50
Refers to general data-agnostic widget functionality
virtual void EnableWidget(bool enable)
Turns widget off and on - default behavior hides widget object but exposes root node. Override for custom behaviour