Skip to content

Commit ba49065

Browse files
fix: server, host, or session owner not populating in-scene placed object table when started (#3177)
* 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. * update Adding change log entry * update Adding PR# to this entry. * style remove whitespace
1 parent c0e65f4 commit ba49065

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
1717

1818
### Fixed
1919

20+
- 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)
2021
- 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)
2122
- Fixed issue where a sever only `NetworkManager` instance would spawn the actual `NetworkPrefab`'s `GameObject` as opposed to creating an instance of it. (#3160)
2223
- 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)

com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs

+9
Original file line numberDiff line numberDiff line change
@@ -1449,6 +1449,15 @@ internal void ServerSpawnSceneObjectsOnStartSweep()
14491449
}
14501450
}
14511451

1452+
// Since we are spawing in-scene placed NetworkObjects for already loaded scenes,
1453+
// we need to add any in-scene placed NetworkObject to our tracking table
1454+
var clearFirst = true;
1455+
foreach (var sceneLoaded in NetworkManager.SceneManager.ScenesLoaded)
1456+
{
1457+
NetworkManager.SceneManager.PopulateScenePlacedObjects(sceneLoaded.Value, clearFirst);
1458+
clearFirst = false;
1459+
}
1460+
14521461
// Notify all in-scene placed NetworkObjects have been spawned
14531462
foreach (var networkObject in networkObjectsToSpawn)
14541463
{

0 commit comments

Comments
 (0)