Tanoda
pb_ObjectInspector.cs
Go to the documentation of this file.
1using UnityEngine;
2using UnityEngine.UI;
3using System.Collections;
4using System.Collections.Generic;
5using System.Reflection;
6
7namespace GILES.Interface
8{
13 [pb_TypeInspector(typeof(object))]
14 public class pb_ObjectInspector : pb_TypeInspector
15 {
16 object value;
17
18 //private static readonly RectOffset RectOffset_Zero = new RectOffset(0,0,0,0);
19 private const int VERTICAL_LAYOUT_SPACING = 0;
20
21 void OnGUIChanged()
22 {
23 SetValue(value);
24 }
25
26 public override void InitializeGUI()
27 {
28 value = GetValue<object>();
29
30 pb_GUIUtility.AddVerticalLayoutGroup(gameObject, new RectOffset(0,0,0,0), VERTICAL_LAYOUT_SPACING, true, false);
31
32 BuildInspectorTree();
33 }
34
35 protected override void OnUpdateGUI()
36 {
37 }
38
39 public void OnValueChange(object val)
40 {
41 }
42
43 void BuildInspectorTree()
44 {
45 if(declaringType == null)
46 {
47 Debug.LogWarning("Inspector is targeting a null or primitive type with no available pb_TypeInspector override, or target is null and using delegates in the parent inspector.");
48 return;
49 }
50
51 string name = GetName();
52 name = name.Substring(name.LastIndexOf(".") + 1);
53
54 GameObject subpanel = pb_GUIUtility.CreateLabeledVerticalPanel(name);
55 subpanel.GetComponent<VerticalLayoutGroup>().padding = new RectOffset(2,2,2,2);
56 subpanel.transform.SetParent(transform);
57
58 foreach(PropertyInfo prop in pb_Reflection.GetSerializableProperties(declaringType, BindingFlags.Public | BindingFlags.Instance))
59 {
60 var temp = pb_InspectorResolver.AddTypeInspector(value, subpanel.transform, prop, null);
61 if (!temp) break;
62
63 temp.parent = this;
64 }
65
66 foreach(FieldInfo field in pb_Reflection.GetSerializableFields(declaringType, BindingFlags.Public | BindingFlags.Instance))
67 {
68
69 var temp = pb_InspectorResolver.AddTypeInspector(value, subpanel.transform, null, field);
70 if (!temp) break;
71
72 temp.parent = this;
73 }
74 }
75 }
76}
UnityEngine.Debug Debug
Definition: TanodaServer.cs:19