Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
CanvasBarDisplayer.cs
Go to the documentation of this file.
1 using System;
4 using UnityEngine;
5 using UnityEngine.UI;
6 
7 namespace droid.Runtime.Prototyping.Displayers.Canvas {
11  [ExecuteInEditMode]
12  [RequireComponent(typeof(Image))]
13  [AddComponentMenu(DisplayerComponentMenuPath._ComponentMenuPath
14  + "Canvas/CanvasBar"
15  + DisplayerComponentMenuPath._Postfix)]
16  public class CanvasBarDisplayer : Displayer {
17  Image _image;
18  [SerializeField] [Range(0.0f, 1.0f)] float _value;
19 
22  public float Value {
23  get { return this._value; }
24  set {
25  this._value = value;
26  this.SetFillAmount(value);
27  }
28  }
29 
33  protected override void Setup() { this._image = this.GetComponent<Image>(); }
34 
38  public void SetFillAmount(float amount) {
39  if (this._image) {
40  this._image.fillAmount = amount;
41  }
42  }
43 
44  //public override void Display(Object o) { throw new NotImplementedException(); }
45 
49  public override void Display(float value) {
50  #if NEODROID_DEBUG
51  DebugPrinting.DisplayPrint(value, this.Identifier, this.Debugging);
52  #endif
53 
54  this.SetFillAmount(value);
55  }
56 
60  public override void Display(Double value) {
61  #if NEODROID_DEBUG
62  DebugPrinting.DisplayPrint(value, this.Identifier, this.Debugging);
63  #endif
64 
65  this.SetFillAmount((float)value);
66  }
67 
71  public override void Display(float[] values) {
72  #if NEODROID_DEBUG
73  DebugPrinting.DisplayPrint(values[0], this.Identifier, this.Debugging);
74  #endif
75 
76  this.SetFillAmount(values[0]);
77  }
78 
82  public override void Display(String value) { throw new NotImplementedException(); }
83 
87  public override void Display(Vector3 value) { throw new NotImplementedException(); }
88 
92  public override void Display(Vector3[] value) { throw new NotImplementedException(); }
93 
97  public override void Display(Points.ValuePoint points) { throw new NotImplementedException(); }
98 
102  public override void Display(Points.ValuePoint[] points) { throw new NotImplementedException(); }
103 
107  public override void Display(Points.StringPoint point) { throw new NotImplementedException(); }
108 
112  public override void Display(Points.StringPoint[] points) { throw new NotImplementedException(); }
113 
114  public override void PlotSeries(Points.ValuePoint[] points) { throw new NotImplementedException(); }
115  }
116 }