From 51c7162af7569061376cf314bd3ca4d5de6e33e0 Mon Sep 17 00:00:00 2001 From: James Frowen Date: Thu, 6 Jul 2023 08:56:23 +0100 Subject: [PATCH] fix: PrepareToSpawnSceneObjects checks netId instead of activeSelf [fixes: #3541] (#3543) * fix: fixing PrepareToSpawnSceneObjects not added enabled objects fixes: https://github.com/MirrorNetworking/Mirror/issues/3541 Should be safe to remove this extra check complete, it is safe to add spawned object to `spawnableObjects`. For now this just changes it to NetId to ensure that the object really is unspawned and not just enabled * Update NetworkClient.cs --------- Co-authored-by: mischa <16416509+vis2k@users.noreply.github.com> --- Assets/Mirror/Core/NetworkClient.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Assets/Mirror/Core/NetworkClient.cs b/Assets/Mirror/Core/NetworkClient.cs index 5685f2058..f3dd99343 100644 --- a/Assets/Mirror/Core/NetworkClient.cs +++ b/Assets/Mirror/Core/NetworkClient.cs @@ -1193,11 +1193,12 @@ public static void PrepareToSpawnSceneObjects() foreach (NetworkIdentity identity in allIdentities) { // add all unspawned NetworkIdentities to spawnable objects - // need to ensure it's not active yet because + // need to check netId to make sure object is not spawned + // fixes: https://github.com/MirrorNetworking/Mirror/issues/3541 // PrepareToSpawnSceneObjects may be called multiple times in case // the ObjectSpawnStarted message is received multiple times. if (Utils.IsSceneObject(identity) && - !identity.gameObject.activeSelf) + identity.netId == 0) { if (spawnableObjects.TryGetValue(identity.sceneId, out NetworkIdentity existingIdentity)) {