@@ -32,53 +32,53 @@ public InspectorDrawer(object target, Type targetType, bool shown, bool showProp
3232 drawer = new List < IReflectorDrawer > ( ) ;
3333 removingDrawers = new HashSet < IReflectorDrawer > ( ) ;
3434 BindingFlags flag = BindingFlags . Static | BindingFlags . Public ;
35- if ( target != null )
35+ if ( target != null )
3636 flag |= BindingFlags . Instance ;
37- if ( allowPrivate = showPrivateFields )
37+ if ( allowPrivate = showPrivateFields )
3838 flag |= BindingFlags . NonPublic ;
3939 this . targetType = targetType ;
4040 elementType = Helper . GetGenericListType ( targetType ) ;
4141 var fields = targetType . GetFields ( flag ) ;
4242 var props = ! showProps ? null : targetType . GetProperties ( flag ) . Where ( prop => prop . GetIndexParameters ( ) . Length == 0 ) . ToArray ( ) ;
4343 isInternalType = ! targetType . IsSubclassOf ( typeof ( MonoBehaviour ) ) || Attribute . IsDefined ( targetType , typeof ( ExecuteInEditMode ) ) ;
44- foreach ( var field in fields )
44+ foreach ( var field in fields )
4545 try {
46- if ( ! showObsolete && Attribute . IsDefined ( field , typeof ( ObsoleteAttribute ) ) )
46+ if ( ! showObsolete && Attribute . IsDefined ( field , typeof ( ObsoleteAttribute ) ) )
4747 continue ;
4848 drawer . Add ( new MethodPropertyDrawer ( field , target , showPrivateFields , showObsolete ) {
4949 AllowReferenceMode = false
5050 } ) ;
51- } catch ( Exception ex ) {
51+ } catch ( Exception ex ) {
5252 Debug . LogException ( ex ) ;
5353 }
54- if ( showProps ) {
54+ if ( showProps ) {
5555 HashSet < string > blacklistedType ;
56- if ( ! Helper . blackListedTypes . TryGetValue ( targetType , out blacklistedType ) ) {
56+ if ( ! Helper . blackListedTypes . TryGetValue ( targetType , out blacklistedType ) ) {
5757 Helper . blackListedTypes . Add ( targetType , blacklistedType = new HashSet < string > ( ) ) ;
58- foreach ( var kvp in Helper . blackListedTypes )
59- if ( kvp . Key . IsAssignableFrom ( targetType ) )
58+ foreach ( var kvp in Helper . blackListedTypes )
59+ if ( kvp . Key . IsAssignableFrom ( targetType ) )
6060 blacklistedType . UnionWith ( kvp . Value ) ;
6161 }
62- foreach ( var prop in props )
62+ foreach ( var prop in props )
6363 try {
64- if ( blacklistedType != null && blacklistedType . Contains ( prop . Name ) )
64+ if ( blacklistedType != null && blacklistedType . Contains ( prop . Name ) )
6565 continue ;
66- if ( ! showObsolete && Attribute . IsDefined ( prop , typeof ( ObsoleteAttribute ) ) )
66+ if ( ! showObsolete && Attribute . IsDefined ( prop , typeof ( ObsoleteAttribute ) ) )
6767 continue ;
6868 drawer . Add ( new MethodPropertyDrawer ( prop , target , showPrivateFields , showObsolete , prop . CanRead && EditorApplication . isPlaying ) {
6969 AllowReferenceMode = false ,
7070 Updatable = isInternalType || Helper . GetState ( prop , false ) ,
7171 ShowUpdatable = ! isInternalType
7272 } ) ;
73- } catch ( Exception ex ) {
73+ } catch ( Exception ex ) {
7474 Debug . LogException ( ex ) ;
7575 }
7676 }
77- if ( allowMethods = showMethods )
77+ if ( allowMethods = showMethods )
7878 AddMethodMenu ( ) ;
79- foreach ( var d in drawer )
79+ foreach ( var d in drawer )
8080 d . OnRequireRedraw += RequireRedraw ;
81- if ( target != null )
81+ if ( target != null )
8282 this . shown = Helper . GetState ( target , shown ) ;
8383 }
8484
@@ -92,29 +92,29 @@ private void AddMethodMenu() {
9292 }
9393
9494 public void Draw ( bool drawHeader = true , bool readOnly = false ) {
95- if ( drawHeader ) {
95+ if ( drawHeader ) {
9696 shown = EditorGUILayout . InspectorTitlebar ( shown , target as UnityObject ) ;
97- if ( target != null )
97+ if ( target != null )
9898 Helper . StoreState ( target , shown ) ;
99- if ( ! shown )
99+ if ( ! shown )
100100 return ;
101101 }
102102 EditorGUI . indentLevel ++ ;
103103 EditorGUILayout . BeginVertical ( ) ;
104- if ( target is Type && GUILayout . Button ( string . Format ( "Inspect Static Members of {0}..." , target ) ) )
104+ if ( target is Type && GUILayout . Button ( string . Format ( "Inspect Static Members of {0}..." , target ) ) )
105105 InspectorChildWindow . OpenStatic ( target as Type , true , allowPrivate , false , true , false , null ) ;
106- else if ( target != null && elementType != null ) {
107- if ( targetType == typeof ( byte [ ] ) ) {
108- if ( hexEdit == null )
106+ else if ( target != null && elementType != null ) {
107+ if ( targetType == typeof ( byte [ ] ) ) {
108+ if ( hexEdit == null )
109109 hexEdit = new HexEdit ( ) ;
110110 hexEdit . data = target as byte [ ] ;
111- if ( hexEdit . data != null )
111+ if ( hexEdit . data != null )
112112 hexEdit . DrawGUI ( false , GUILayout . MinHeight ( EditorGUIUtility . singleLineHeight * 3 ) , GUILayout . ExpandHeight ( true ) ) ;
113- } else if ( showListEdit = EditorGUILayout . Foldout ( showListEdit , string . Format ( "Edit List [{0} Items]" , ( target as IList ) . Count ) ) ) {
114- if ( arrayHandler == null ) {
115- if ( arrayContentDrawer == null ) {
113+ } else if ( showListEdit = EditorGUILayout . Foldout ( showListEdit , string . Format ( "Edit List [{0} Items]" , ( target as IList ) . Count ) ) ) {
114+ if ( arrayHandler == null ) {
115+ if ( arrayContentDrawer == null ) {
116116 arrayContentDrawer = new List < MethodPropertyDrawer > ( ) ;
117- for ( int i = 0 ; i < ( target as IList ) . Count ; i ++ )
117+ for ( int i = 0 ; i < ( target as IList ) . Count ; i ++ )
118118 ListAddItem ( ) ;
119119 }
120120 arrayHandler = new ReorderableList ( target as IList , elementType ) {
@@ -123,7 +123,7 @@ public void Draw(bool drawHeader = true, bool readOnly = false) {
123123 drawElementCallback = ( r , i , c , d ) => {
124124 arrayContentDrawer [ i ] . Value = ( target as IList ) [ i ] ;
125125 arrayContentDrawer [ i ] . Draw ( false , Helper . ScaleRect ( r , offsetHeight : - 2 ) ) ;
126- if ( arrayContentDrawer [ i ] . Changed )
126+ if ( arrayContentDrawer [ i ] . Changed )
127127 ( target as IList ) [ i ] = arrayContentDrawer [ i ] . Value ;
128128 } ,
129129 drawHeaderCallback = r => GUI . Label ( r , target . ToString ( ) , EditorStyles . miniBoldLabel ) ,
@@ -142,14 +142,14 @@ public void Draw(bool drawHeader = true, bool readOnly = false) {
142142 arrayHandler . DoLayoutList ( ) ;
143143 }
144144 }
145- if ( removingDrawers . Count > 0 ) {
145+ if ( removingDrawers . Count > 0 ) {
146146 drawer . RemoveAll ( removingDrawers . Contains ) ;
147147 removingDrawers . Clear ( ) ;
148148 }
149- foreach ( var item in drawer ) {
149+ foreach ( var item in drawer ) {
150150 var methodDrawer = item as ComponentMethodDrawer ;
151151 var fieldDrawer = item as MethodPropertyDrawer ;
152- if ( methodDrawer != null ) {
152+ if ( methodDrawer != null ) {
153153 EditorGUI . indentLevel -- ;
154154 EditorGUILayout . BeginHorizontal ( ) ;
155155 EditorGUILayout . LabelField ( GUIContent . none , GUILayout . Width ( EditorGUIUtility . singleLineHeight ) ) ;
@@ -158,20 +158,20 @@ public void Draw(bool drawHeader = true, bool readOnly = false) {
158158 EditorGUILayout . EndVertical ( ) ;
159159 EditorGUILayout . EndHorizontal ( ) ;
160160 EditorGUI . indentLevel ++ ;
161- } else if ( item != null ) {
162- if ( item . Info != null && ! string . IsNullOrEmpty ( searchText ) && item . Info . Name . IndexOf ( searchText , StringComparison . CurrentCultureIgnoreCase ) < 0 )
161+ } else if ( item != null ) {
162+ if ( item . Info != null && ! string . IsNullOrEmpty ( searchText ) && item . Info . Name . IndexOf ( searchText , StringComparison . CurrentCultureIgnoreCase ) < 0 )
163163 continue ;
164- if ( fieldDrawer != null )
164+ if ( fieldDrawer != null )
165165 fieldDrawer . Draw ( readOnly ) ;
166166 else
167167 item . Draw ( ) ;
168168 changed |= item . UpdateIfChanged ( ) ;
169169 }
170170 }
171- if ( allowMethods ) {
171+ if ( allowMethods ) {
172172 GUILayout . BeginHorizontal ( ) ;
173173 GUILayout . FlexibleSpace ( ) ;
174- if ( GUILayout . Button ( new GUIContent ( "+" , "Add Method / Index Properties Watcher" ) , EditorStyles . miniButton , GUILayout . ExpandWidth ( false ) ) )
174+ if ( GUILayout . Button ( new GUIContent ( "+" , "Add Method / Index Properties Watcher" ) , EditorStyles . miniButton , GUILayout . ExpandWidth ( false ) ) )
175175 AddMethodMenu ( ) ;
176176 GUILayout . EndHorizontal ( ) ;
177177 }
@@ -186,20 +186,20 @@ private void ListAddItem(object value = null) {
186186 }
187187
188188 public void UpdateValues ( bool updateProps ) {
189- if ( target == null ) return ;
190- foreach ( var drawerItem in drawer ) {
189+ if ( target == null ) return ;
190+ foreach ( var drawerItem in drawer ) {
191191 var propDrawer = drawerItem as MethodPropertyDrawer ;
192- if ( propDrawer == null )
192+ if ( propDrawer == null )
193193 continue ;
194194 var isPropInfo = propDrawer . Info is PropertyInfo ;
195- if ( ! isInternalType && ( ! updateProps || ! propDrawer . Updatable ) && isPropInfo )
195+ if ( ! isInternalType && ( ! updateProps || ! propDrawer . Updatable ) && isPropInfo )
196196 continue ;
197197 propDrawer . UpdateValue ( ) ;
198198 }
199199 }
200200
201201 private void RequireRedraw ( ) {
202- if ( target != null && OnRequireRedraw != null )
202+ if ( target != null && OnRequireRedraw != null )
203203 OnRequireRedraw ( ) ;
204204 }
205205 }
0 commit comments