Tanoda
pb_QuaternionInspector.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(Quaternion))]
11 public class pb_QuaternionInspector : pb_TypeInspector
12 {
13 Quaternion quaternion;
14
15 public UnityEngine.UI.Text title;
16
17 public UnityEngine.UI.InputField
22
23 void OnGUIChanged()
24 {
25 SetValue(quaternion);
26 }
27
28 public override void InitializeGUI()
29 {
30 title.text = GetName().SplitCamelCase();
31
32#if UNITY_5_2
33 input_x.onValueChange.AddListener( OnValueChange_X );
34 input_y.onValueChange.AddListener( OnValueChange_Y );
35 input_z.onValueChange.AddListener( OnValueChange_Z );
36 input_w.onValueChange.AddListener( OnValueChange_W );
37#else
38 input_x.onValueChanged.AddListener( OnValueChange_X );
39 input_y.onValueChanged.AddListener( OnValueChange_Y );
40 input_z.onValueChanged.AddListener( OnValueChange_Z );
41 input_w.onValueChanged.AddListener( OnValueChange_W );
42#endif
43 }
44
45 protected override void OnUpdateGUI()
46 {
47 quaternion = GetValue<Quaternion>();
48 input_x.text = quaternion.x.ToString();
49 input_y.text = quaternion.y.ToString();
50 input_z.text = quaternion.z.ToString();
51 input_w.text = quaternion.w.ToString();
52 }
53
54 public void OnValueChange_X(string val)
55 {
56 float v;
57
58 if(float.TryParse(val, out v))
59 {
60 quaternion.x = v;
61 OnGUIChanged();
62 }
63 }
64
65 public void OnValueChange_Y(string val)
66 {
67 float v;
68
69 if(float.TryParse(val, out v))
70 {
71 quaternion.y = v;
72 OnGUIChanged();
73 }
74 }
75
76 public void OnValueChange_Z(string val)
77 {
78 float v;
79
80 if(float.TryParse(val, out v))
81 {
82 quaternion.z = v;
83 OnGUIChanged();
84 }
85 }
86
87 public void OnValueChange_W(string val)
88 {
89 float v;
90
91 if(float.TryParse(val, out v))
92 {
93 quaternion.w = v;
94 OnGUIChanged();
95 }
96 }
97 }
98}