Tanoda
pb_Vector2Inspector.cs
Go to the documentation of this file.
1using UnityEngine;
2using System.Collections;
3using System.Reflection;
4
5namespace GILES.Interface
6{
10 [pb_TypeInspector(typeof(Vector2))]
11 public class pb_Vector2Inspector : pb_TypeInspector
12 {
13 Vector2 vector;
14
15 public UnityEngine.UI.Text title;
16
17 public UnityEngine.UI.InputField input_x, input_y;
18
19 void OnGUIChanged()
20 {
21 SetValue(vector);
22 }
23
24 public override void InitializeGUI()
25 {
26 title.text = GetName().SplitCamelCase();
27#if UNITY_5_2
28 input_x.onValueChange.AddListener( OnValueChange_X );
29 input_y.onValueChange.AddListener( OnValueChange_Y );
30#else
31 input_x.onValueChanged.AddListener( OnValueChange_X );
32 input_y.onValueChanged.AddListener( OnValueChange_Y );
33#endif
34 }
35
36 protected override void OnUpdateGUI()
37 {
38 vector = GetValue<Vector2>();
39 input_x.text = vector.x.ToString("F4");
40 input_y.text = vector.y.ToString("F4");
41 }
42
43 public void OnValueChange_X(string val)
44 {
45 vector.x = Macro.StoF(val);
46 OnGUIChanged();
47 }
48
49 public void OnValueChange_Y(string val)
50 {
51 vector.y = Macro.StoF(val);
52 OnGUIChanged();
53 }
54 }
55}
Definition: Macro.cs:12
static float StoF(string value)
Definition: Macro.cs:24