11using UnityEditor ;
22using UnityEngine ;
3+ using System . Reflection ;
34
45namespace UXF . EditorUtils
56{
@@ -17,27 +18,47 @@ void OnEnable()
1718
1819 public override void OnInspectorGUI ( )
1920 {
21+ EditorGUI . BeginDisabledGroup ( true ) ;
22+ EditorGUILayout . PropertyField ( serializedObject . FindProperty ( "m_Script" ) ) ;
23+ EditorGUI . EndDisabledGroup ( ) ;
24+
2025 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+
2242 EditorGUILayout . Space ( ) ;
43+ GUI . enabled = false ;
2344
24- serializedObject . Update ( ) ;
25- EditorGUILayout . PropertyField ( customHeader ) ;
45+ EditorGUILayout . LabelField ( customHeader . displayName ) ;
2646 EditorGUI . indentLevel += 1 ;
2747
2848 foreach ( SerializedProperty element in customHeader )
2949 {
30- GUI . enabled = false ;
3150 EditorGUILayout . TextField ( element . stringValue ) ;
32- GUI . enabled = true ;
3351 }
3452 EditorGUI . indentLevel -= 1 ;
3553
3654 EditorGUILayout . Space ( ) ;
37- GUI . enabled = false ;
38- EditorGUILayout . PropertyField ( measurementDescriptor ) ;
39- GUI . enabled = true ;
4055
56+ EditorGUILayout . LabelField ( measurementDescriptor . displayName ) ;
57+ EditorGUI . indentLevel += 1 ;
58+ EditorGUILayout . TextField ( measurementDescriptor . stringValue ) ;
59+ EditorGUI . indentLevel -= 1 ;
60+
61+ GUI . enabled = true ;
4162 serializedObject . ApplyModifiedProperties ( ) ;
4263 }
4364 }
0 commit comments