From 30e7fef024c54dd2279f9e5cb47feb198c8a1f9e Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Sun, 15 Dec 2024 21:22:15 -0600 Subject: [PATCH 1/4] fix This fixes the issue with the server, host, or session owner not adding in-scene placed NetworkObjects to its internal table if the scene was loaded prior to starting the NetworkManager. --- .../Runtime/Spawning/NetworkSpawnManager.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs b/com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs index ed0b0348b7..2a8ecb84bd 100644 --- a/com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs @@ -1449,6 +1449,15 @@ internal void ServerSpawnSceneObjectsOnStartSweep() } } + // Since we are spawing in-scene placed NetworkObjects for already loaded scenes, + // we need to add any in-scene placed NetworkObject to our tracking table + var clearFirst = true; + foreach(var sceneLoaded in NetworkManager.SceneManager.ScenesLoaded) + { + NetworkManager.SceneManager.PopulateScenePlacedObjects(sceneLoaded.Value, clearFirst); + clearFirst = false; + } + // Notify all in-scene placed NetworkObjects have been spawned foreach (var networkObject in networkObjectsToSpawn) { From 685c284daeb0632c787f07df9a0c69d6819fa1a1 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Sun, 15 Dec 2024 23:16:52 -0600 Subject: [PATCH 2/4] update Adding change log entry --- com.unity.netcode.gameobjects/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index ff93d501ee..cf3dc07506 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -17,6 +17,7 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Fixed +- Fixed issue where the server, host, or session owner would not populate the in-scene place `NetworkObject` table if the scene was loaded prior to starting the `NetworkManager`. - Fixed issue where the `NetworkObjectIdHash` value could be incorrect when entering play mode while still in prefab edit mode with pending changes and using MPPM. (#3162) - Fixed issue where a sever only `NetworkManager` instance would spawn the actual `NetworkPrefab`'s `GameObject` as opposed to creating an instance of it. (#3160) - Fixed issue where only the session owner (as opposed to all clients) would handle spawning prefab overrides properly when using a distributed authority network topology. (#3160) From f4705a6fe729cf8f5e149b18ae7b7677c2736280 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Sun, 15 Dec 2024 23:21:36 -0600 Subject: [PATCH 3/4] update Adding PR# to this entry. --- com.unity.netcode.gameobjects/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index cf3dc07506..e6930d1077 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -17,7 +17,7 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Fixed -- Fixed issue where the server, host, or session owner would not populate the in-scene place `NetworkObject` table if the scene was loaded prior to starting the `NetworkManager`. +- Fixed issue where the server, host, or session owner would not populate the in-scene place `NetworkObject` table if the scene was loaded prior to starting the `NetworkManager`. (#3177) - Fixed issue where the `NetworkObjectIdHash` value could be incorrect when entering play mode while still in prefab edit mode with pending changes and using MPPM. (#3162) - Fixed issue where a sever only `NetworkManager` instance would spawn the actual `NetworkPrefab`'s `GameObject` as opposed to creating an instance of it. (#3160) - Fixed issue where only the session owner (as opposed to all clients) would handle spawning prefab overrides properly when using a distributed authority network topology. (#3160) From 3e070655fa6077b317984c8372a362b48889ebe0 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Sun, 15 Dec 2024 23:38:57 -0600 Subject: [PATCH 4/4] style remove whitespace --- .../Runtime/Spawning/NetworkSpawnManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs b/com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs index 2a8ecb84bd..854bc8fba2 100644 --- a/com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs @@ -1452,12 +1452,12 @@ internal void ServerSpawnSceneObjectsOnStartSweep() // Since we are spawing in-scene placed NetworkObjects for already loaded scenes, // we need to add any in-scene placed NetworkObject to our tracking table var clearFirst = true; - foreach(var sceneLoaded in NetworkManager.SceneManager.ScenesLoaded) + foreach (var sceneLoaded in NetworkManager.SceneManager.ScenesLoaded) { NetworkManager.SceneManager.PopulateScenePlacedObjects(sceneLoaded.Value, clearFirst); clearFirst = false; } - + // Notify all in-scene placed NetworkObjects have been spawned foreach (var networkObject in networkObjectsToSpawn) {