AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
NoteDataProvider.cs
Go to the documentation of this file.
1 // Licensed under the MIT License. See LICENSE in the project root for license information.
2 
3 using System.Collections;
4 using System.Collections.Generic;
5 using UnityEngine;
6 
7 namespace HoloToolkit.Examples.InteractiveElements
8 {
15  public class NoteDataProvider : MonoBehaviour
16  {
18 
20 
25  public Dictionary<string, List<string>> Data = new Dictionary<string, List<string>>
26  {
27  {
28  "Normal",
29  new List<string>(){
30  "Please contact me.",
31  "Please check\nthis component.",
32  "Please provide\nmore information."
33  }
34  },
35  {
36  "Warning", new List<string>(){
37  "Component needs to\nbe repaired.",
38  "Component needs to\nbe replaced.",
39  "Please provide\nmore information.",
40  "Wear a helmet",
41  "Use a mask",
42  "Wear boots",
43  "Take care:\nfire hazard.",
44  "Take care:\nchemicals."
45  }
46  }
47  };
48 
54  public void NoteTypeButtonSelected()
55  {
56  if (SourceSet.SelectedIndices.Count == 0)
57  {
58  // No item selected, this is only possible when your SourceSet
59  // selection type is set to "Multiple".
60  return;
61  }
62 
63  // In this example we are only interested in the first selected
64  // item. If you allow multiple selection for the SourceSet you
65  // might want to have some more logic here
66  int interactivePos = SourceSet.SelectedIndices[0];
67  InteractiveToggle toggle = SourceSet.Interactives[interactivePos];
68 
69  LabelTheme label = toggle.gameObject.GetComponent<LabelTheme>();
70  if (label == null)
71  {
72  // The selected InteractiveToggle does not have a LabelTheme
73  // attached, so it can not be determined what text blocks
74  // should be shown in the InteractiveGroup.
75  Debug.LogWarning("Please attach a LabelTheme to the " +
76  "InteractiveToggle named \"" + toggle.gameObject.name + "\"");
77  }
78  else
79  {
80  TargetGroup.Titles = Data[label.Default];
81  TargetGroup.UpdateData();
82  }
83  }
84 
89  public void SendNote()
90  {
91  InteractiveSet interactiveSet = TargetGroup.GetInteractiveSet();
92  foreach (int index in interactiveSet.SelectedIndices)
93  {
94  Debug.Log("Send new note: " + TargetGroup.Titles[index].Replace("\n", " "));
95  }
96  if (interactiveSet.SelectedIndices.Count == 0)
97  {
98  Debug.Log("Please select a note.");
99  }
100  }
101  }
102 }
A controller for managing multiple radial or tab type buttons
A theme for handling the label string on the toggle button
Definition: LabelTheme.cs:13
InteractiveToggle expands Interactive to expose selection or toggle states.
void SendNote()
The user pressed the send button. If something is selected it will be logged.
void NoteTypeButtonSelected()
called when clicked on one of the buttons at the SourceSet to modify the TargetGroup data according t...
NoteDataProvider takes the selected Label text of the pressed Interactive and fills the TargetGroup w...
void UpdateData()
position interactives and set title text.