Skip to content

Commit 93b645f

Browse files
update
Implementing some suggested changes from PR review.
1 parent 5662003 commit 93b645f

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

com.unity.netcode.gameobjects/Runtime/Components/Helpers/AttachableBehaviour.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff 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

com.unity.netcode.gameobjects/Runtime/Components/Helpers/ComponentController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)