Skip to content

Commit 0db4e41

Browse files
fix
Fixing issue with logic for scene migration synchronization.
1 parent 544baf7 commit 0db4e41

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,8 +1665,6 @@ internal void ShutdownInternal()
16651665
// can unsubscribe from tick updates and such.
16661666
NetworkTimeSystem?.Shutdown();
16671667
NetworkTickSystem = null;
1668-
SpawnManager?.Shutdown();
1669-
SpawnManager = null;
16701668
}
16711669

16721670

com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,20 +3289,18 @@ internal bool UpdateForSceneChanges()
32893289
// the NetworkManager is shutting down, the NetworkObject is not spawned, it is an in-scene placed
32903290
// NetworkObject, or the GameObject's current scene handle is the same as the SceneOriginHandle
32913291
if (!SceneMigrationSynchronization || !IsSpawned || NetworkManager == null || NetworkManager.ShutdownInProgress ||
3292-
!NetworkManager.NetworkConfig.EnableSceneManagement || IsSceneObject != false || !gameObject || gameObject.scene.handle == SceneOriginHandle)
3292+
!NetworkManager.NetworkConfig.EnableSceneManagement || IsSceneObject != false || !gameObject)
32933293
{
3294-
// If this NetworkObject did register for SceneMigrationSynchronization and scene management is enabled and the gameObject is null.
3295-
if (SceneMigrationSynchronization && NetworkManager.NetworkConfig.EnableSceneManagement && (IsSceneObject != false || !gameObject))
3296-
{
3297-
// then mark this instance to be removed from the scene migration synchronization list.
3298-
return false;
3299-
}
3300-
3294+
// Stop checking for a scene migration
3295+
return false;
3296+
}
3297+
else if (gameObject.scene.handle != SceneOriginHandle)
3298+
{
3299+
// If the scene handle has changed, then update and send notification
3300+
SceneChangedUpdate(gameObject.scene, true);
33013301
}
33023302

3303-
// Otherwise, this has to be a dynamically spawned NetworkObject that has been
3304-
// migrated to a new scene.
3305-
SceneChangedUpdate(gameObject.scene, true);
3303+
// Return true (continue checking for scene migration)
33063304
return true;
33073305
}
33083306

0 commit comments

Comments
 (0)