Game Development Reference
In-Depth Information
36 foreach(var prop in
typeof(ClassWithProperties).GetProperties(BindingFlags.Public |
BindingFlags.Instance))
37 {
38 //If integer property
39 if(prop.PropertyType.Equals(typeof(int)))
40 {
41 prop.SetValue(CP, EditorGUI.IntField(LayoutRect, prop.Name,
(int)prop.GetValue(CP,null)), null);
42 LayoutRect = new Rect(LayoutRect.x, LayoutRect.y +
RowHeight+RowSpacing, LayoutRect.width, RowHeight);
43 }
44
45 //If float property
46 if(prop.PropertyType.Equals(typeof(float)))
47 {
48 prop.SetValue(CP, EditorGUI.FloatField(LayoutRect, prop.Name,
(float)prop.GetValue(CP,null)), null);
49 LayoutRect = new Rect(LayoutRect.x, LayoutRect.y +
RowHeight+RowSpacing, LayoutRect.width, RowHeight);
50 }
51
52 //If color property
53 if(prop.PropertyType.Equals(typeof(Color)))
54 {
55 prop.SetValue(CP, EditorGUI.ColorField(LayoutRect, prop.Name,
(Color)prop.GetValue(CP,null)), null);
56 LayoutRect = new Rect(LayoutRect.x, LayoutRect.y +
RowHeight+RowSpacing, LayoutRect.width, RowHeight);
57 }
58 }
59
60 //Update inspector height
61 InspectorHeight = LayoutRect.y-position.y;
62
63 EditorGUI.indentLevel = indent;
64 EditorGUI.EndProperty();
65 }
 
Search WWH ::




Custom Search