1
1
using UnityEditor ;
2
2
using UnityEngine ;
3
+ using System . Reflection ;
3
4
4
5
namespace UXF . EditorUtils
5
6
{
@@ -17,27 +18,47 @@ void OnEnable()
17
18
18
19
public override void OnInspectorGUI ( )
19
20
{
21
+ EditorGUI . BeginDisabledGroup ( true ) ;
22
+ EditorGUILayout . PropertyField ( serializedObject . FindProperty ( "m_Script" ) ) ;
23
+ EditorGUI . EndDisabledGroup ( ) ;
24
+
20
25
serializedObject . Update ( ) ;
21
- DrawDefaultInspector ( ) ;
26
+
27
+ FieldInfo [ ] childFields = target . GetType ( ) . GetFields ( BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic ) ;
28
+
29
+ // draw all default fields
30
+ foreach ( FieldInfo field in childFields )
31
+ {
32
+ if ( field . IsPublic || field . GetCustomAttribute ( typeof ( SerializeField ) ) != null )
33
+ {
34
+ if ( field . Name != measurementDescriptor . name && field . Name != customHeader . name )
35
+ {
36
+ var prop = serializedObject . FindProperty ( field . Name ) ;
37
+ EditorGUILayout . PropertyField ( prop ) ;
38
+ }
39
+ }
40
+ }
41
+
22
42
EditorGUILayout . Space ( ) ;
43
+ GUI . enabled = false ;
23
44
24
- serializedObject . Update ( ) ;
25
- EditorGUILayout . PropertyField ( customHeader ) ;
45
+ EditorGUILayout . LabelField ( customHeader . displayName ) ;
26
46
EditorGUI . indentLevel += 1 ;
27
47
28
48
foreach ( SerializedProperty element in customHeader )
29
49
{
30
- GUI . enabled = false ;
31
50
EditorGUILayout . TextField ( element . stringValue ) ;
32
- GUI . enabled = true ;
33
51
}
34
52
EditorGUI . indentLevel -= 1 ;
35
53
36
54
EditorGUILayout . Space ( ) ;
37
- GUI . enabled = false ;
38
- EditorGUILayout . PropertyField ( measurementDescriptor ) ;
39
- GUI . enabled = true ;
40
55
56
+ EditorGUILayout . LabelField ( measurementDescriptor . displayName ) ;
57
+ EditorGUI . indentLevel += 1 ;
58
+ EditorGUILayout . TextField ( measurementDescriptor . stringValue ) ;
59
+ EditorGUI . indentLevel -= 1 ;
60
+
61
+ GUI . enabled = true ;
41
62
serializedObject . ApplyModifiedProperties ( ) ;
42
63
}
43
64
}
0 commit comments