Tanoda
pb_IntInspector.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(int))]
11 public class pb_IntInspector : pb_TypeInspector
12 {
13 int value;
14
15 public UnityEngine.UI.Text title;
16 public UnityEngine.UI.InputField input;
17
18 void OnGUIChanged()
19 {
20 SetValue(value);
21 }
22
23 public override void InitializeGUI()
24 {
25 title.text = GetName().SplitCamelCase();
26#if UNITY_5_2
27 input.onValueChange.AddListener( OnValueChange );
28#else
29 input.onValueChanged.AddListener( OnValueChange );
30#endif
31 }
32
33 protected override void OnUpdateGUI()
34 {
35 value = GetValue<int>();
36 input.text = value.ToString();
37 }
38
39 public void OnValueChange(string val)
40 {
41 int v;
42
43 if(int.TryParse(val, out v))
44 {
45 value = v;
46 OnGUIChanged();
47 }
48 }
49 }
50}
UnityEngine.UI.InputField input