Skip to content

Commit 8e348c1

Browse files
fix: IsSpawnedObjectsPendingInDontDestroyOnLoad should only be set when LoadSceneMode.Single (#2330)
* fix MTT-4681 this fix assures that IsSpawnedObjectsPendingInDontDestroyOnLoad is only set to true when LoadSceneMode = LoadSceneMode.Singleonly. * update updating changelog.
1 parent d9ab3a7 commit 8e348c1

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
3434
- Optimized bandwidth usage by encoding most integer fields using variable-length encoding. (#2276)
3535

3636
### Fixed
37-
37+
- Fixed `IsSpawnedObjectsPendingInDontDestroyOnLoad` is only set to true when loading a scene using `LoadSceneMode.Singleonly`. (#2330)
3838
- Fixed issue where `NetworkTransform` components nested under a parent with a `NetworkObject` component (i.e. network prefab) would not have their associated `GameObject`'s transform synchronized. (#2298)
3939
- Fixed issue where `NetworkObject`s that failed to instantiate could cause the entire synchronization pipeline to be disrupted/halted for a connecting client. (#2298)
4040
- Fixed issue where in-scene placed `NetworkObject`s nested under a `GameObject` would be added to the orphaned children list causing continual console warning log messages. (#2298)

com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -862,16 +862,6 @@ private SceneEventProgress ValidateSceneEvent(string sceneName, bool isUnloading
862862

863863
SceneEventProgressTracking.Add(sceneEventProgress.Guid, sceneEventProgress);
864864

865-
if (!isUnloading)
866-
{
867-
// The Condition: While a scene is asynchronously loaded in single loading scene mode, if any new NetworkObjects are spawned
868-
// they need to be moved into the do not destroy temporary scene
869-
// When it is set: Just before starting the asynchronous loading call
870-
// When it is unset: After the scene has loaded, the PopulateScenePlacedObjects is called, and all NetworkObjects in the do
871-
// not destroy temporary scene are moved into the active scene
872-
IsSpawnedObjectsPendingInDontDestroyOnLoad = true;
873-
}
874-
875865
m_IsSceneEventActive = true;
876866

877867
// Set our callback delegate handler for completion
@@ -1162,6 +1152,13 @@ public SceneEventProgressStatus LoadScene(string sceneName, LoadSceneMode loadSc
11621152

11631153
if (sceneEventData.LoadSceneMode == LoadSceneMode.Single)
11641154
{
1155+
// The Condition: While a scene is asynchronously loaded in single loading scene mode, if any new NetworkObjects are spawned
1156+
// they need to be moved into the do not destroy temporary scene
1157+
// When it is set: Just before starting the asynchronous loading call
1158+
// When it is unset: After the scene has loaded, the PopulateScenePlacedObjects is called, and all NetworkObjects in the do
1159+
// not destroy temporary scene are moved into the active scene
1160+
IsSpawnedObjectsPendingInDontDestroyOnLoad = true;
1161+
11651162
// Destroy current scene objects before switching.
11661163
m_NetworkManager.SpawnManager.ServerDestroySpawnedSceneObjects();
11671164

0 commit comments

Comments
 (0)