From 5d066f3cd16a0773cb3921fd761323e9a8e0616d Mon Sep 17 00:00:00 2001 From: vis2k Date: Fri, 6 Jan 2023 14:25:49 +0100 Subject: [PATCH] fix: #3330 #2422 Mirror now ignores objects which inactive parents --- Assets/Mirror/Core/NetworkServer.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Assets/Mirror/Core/NetworkServer.cs b/Assets/Mirror/Core/NetworkServer.cs index 18462317e..d85d7ce75 100644 --- a/Assets/Mirror/Core/NetworkServer.cs +++ b/Assets/Mirror/Core/NetworkServer.cs @@ -1230,7 +1230,15 @@ public static bool SpawnObjects() if (!active) return false; - NetworkIdentity[] identities = Resources.FindObjectsOfTypeAll(); + // find all NetworkIdentities in the scene. + // all of them are disabled because of NetworkScenePostProcess. + // however, ignore identities under disabled parent objects. + // users would put them under disabled parents to 'deactivate' them. + // those should not be used by Mirror at all. + // fixes: https://github.com/MirrorNetworking/Mirror/issues/3330 + IEnumerable identities = Resources.FindObjectsOfTypeAll() + .Where(identity => identity.transform.parent == null || + identity.transform.parent.gameObject.activeInHierarchy); // first pass: activate all scene objects foreach (NetworkIdentity identity in identities)