Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
CanvasTextDisplayer.cs
Go to the documentation of this file.
1 using System;
2 using System.Globalization;
5 using UnityEngine;
6 using UnityEngine.UI;
7 
8 namespace droid.Runtime.Prototyping.Displayers.Canvas {
12  [ExecuteInEditMode]
13  [RequireComponent(typeof(Text))]
14  [AddComponentMenu(DisplayerComponentMenuPath._ComponentMenuPath
15  + "Canvas/CanvasText"
16  + DisplayerComponentMenuPath._Postfix)]
17  public class CanvasTextDisplayer : Displayer {
18  Text _text_component;
19 
23  protected override void Setup() { this._text_component = this.GetComponent<Text>(); }
24 
25  //public override void Display(Object o) { throw new NotImplementedException(); }
26 
30  public override void Display(float value) {
31  #if NEODROID_DEBUG
32  DebugPrinting.DisplayPrint(value, this.Identifier, this.Debugging);
33  #endif
34 
35  this.SetText(value.ToString(CultureInfo.InvariantCulture));
36  }
37 
41  public override void Display(Double value) {
42  #if NEODROID_DEBUG
43  DebugPrinting.DisplayPrint(value, this.Identifier, this.Debugging);
44  #endif
45 
46  this.SetText(value.ToString(CultureInfo.InvariantCulture));
47  }
48 
52  public override void Display(float[] values) {
53  #if NEODROID_DEBUG
54  DebugPrinting.DisplayPrint(values[0], this.Identifier, this.Debugging);
55  #endif
56 
57  this.SetText(values[0].ToString());
58  }
59 
63  public override void Display(String value) {
64  #if NEODROID_DEBUG
65  DebugPrinting.DisplayPrint(value, this.Identifier, this.Debugging);
66  #endif
67 
68  this.SetText(value);
69  }
70 
74  public override void Display(Vector3 value) {
75  #if NEODROID_DEBUG
76  DebugPrinting.DisplayPrint(value, this.Identifier, this.Debugging);
77  #endif
78 
79  this.SetText(value.ToString());
80  }
81 
85  public override void Display(Vector3[] value) {
86  #if NEODROID_DEBUG
87  DebugPrinting.DisplayPrint(value, this.Identifier, this.Debugging);
88  #endif
89 
90  this.SetText(value.ToString());
91  }
92 
96  public override void Display(Points.ValuePoint points) {
97  #if NEODROID_DEBUG
98  DebugPrinting.DisplayPrint(points, this.Identifier, this.Debugging);
99  #endif
100 
101  this.SetText(points.ToString());
102  }
103 
107  public override void Display(Points.ValuePoint[] points) {
108  #if NEODROID_DEBUG
109  DebugPrinting.DisplayPrint(points, this.Identifier, this.Debugging);
110  #endif
111 
112  this.SetText(points.ToString());
113  }
114 
118  public override void Display(Points.StringPoint point) {
119  #if NEODROID_DEBUG
120  DebugPrinting.DisplayPrint(point, this.Identifier, this.Debugging);
121  #endif
122 
123  this.SetText(point.ToString());
124  }
125 
129  public override void Display(Points.StringPoint[] points) {
130  #if NEODROID_DEBUG
131  DebugPrinting.DisplayPrint(points, this.Identifier, this.Debugging);
132  #endif
133 
134  this.SetText(points.ToString());
135  }
136 
137  public override void PlotSeries(Points.ValuePoint[] points) {
138  #if NEODROID_DEBUG
139  DebugPrinting.DisplayPrint(points, this.Identifier, this.Debugging);
140  #endif
141 
142  this.SetText(points.ToString());
143  }
144 
148  public void SetText(string text) {
149  if (this._text_component) {
150  this._text_component.text = text;
151  }
152  }
153  }
154 }