Skip to content

Commit 5d9f741

Browse files
Update NetworkObject.cs
1 parent 5ea9d4a commit 5d9f741

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,19 +396,28 @@ internal void UnifiedValidation()
396396

397397
private void SortToTop()
398398
{
399+
if (gameObject == null)
400+
{
401+
return;
402+
}
399403
// Move the bridge to the top
400-
while (UnityEditorInternal.ComponentUtility.MoveComponentUp(NetworkObjectBridge))
404+
while (NetworkObjectBridge != null && UnityEditorInternal.ComponentUtility.MoveComponentUp(NetworkObjectBridge))
401405
{
402406
// Keep moving until it can't go higher
403407
}
404408

405409
// Now move the GhostAdapter to the top so it is above NetworkObjectBridge
406-
while (UnityEditorInternal.ComponentUtility.MoveComponentUp(GhostAdapter))
410+
while (GhostAdapter != null && UnityEditorInternal.ComponentUtility.MoveComponentUp(GhostAdapter))
407411
{
408412
// Keep moving until it can't go higher
409413
}
410-
411-
EditorUtility.SetDirty(gameObject);
414+
415+
if (gameObject != null)
416+
{
417+
EditorUtility.SetDirty(gameObject);
418+
return;
419+
}
420+
412421
}
413422
#endif
414423
#endif

0 commit comments

Comments
 (0)