File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed
com.unity.netcode.gameobjects/Runtime/Components/Helpers Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -96,11 +96,7 @@ protected virtual void OnValidate()
9696 }
9797 foreach ( var componentController in ComponentControllers )
9898 {
99- if ( componentController == null )
100- {
101- continue ;
102- }
103- componentController . OnValidate ( ) ;
99+ componentController ? . OnValidate ( ) ;
104100 }
105101 }
106102
Original file line number Diff line number Diff line change @@ -255,7 +255,7 @@ protected virtual void OnValidate()
255255 }
256256
257257 var propertyInfo = Components [ i ] . Component . GetType ( ) . GetProperty ( "enabled" , BindingFlags . Instance | BindingFlags . Public ) ;
258- if ( propertyInfo == null && propertyInfo . PropertyType != typeof ( bool ) )
258+ if ( propertyInfo == null || propertyInfo . PropertyType != typeof ( bool ) )
259259 {
260260 Debug . LogWarning ( $ "{ Components [ i ] . Component . name } does not contain a public enabled property! (Removing)") ;
261261 Components . RemoveAt ( i ) ;
@@ -291,13 +291,13 @@ protected virtual void OnValidate()
291291 gameObjectsToScan . Clear ( ) ;
292292
293293 // Final (third) pass is to name each list element item as the component is normally viewed in the inspector view.
294- for ( int i = 0 ; i < Components . Count ; i ++ )
294+ foreach ( var componentEntry in Components )
295295 {
296- if ( ! Components [ i ] . Component )
296+ if ( ! componentEntry . Component )
297297 {
298298 continue ;
299299 }
300- Components [ i ] . name = GetComponentNameFormatted ( Components [ i ] . Component ) ;
300+ componentEntry . name = GetComponentNameFormatted ( componentEntry . Component ) ;
301301 }
302302 }
303303#endif
You can’t perform that action at this time.
0 commit comments