You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: CreateObjectMessage created NetworkObjects can get destroyed during client synchronization [MTT-7539] (#2735)
* fix
This resolves the issue where any NetworkObjects created during client synchronization when scene management is enabled. client synchronization mode is set to LoadSceneMode.Single, and the active scene (where the NetworkObjects are created) is unloaded during synchronization.
* fix
This fixes the exception that can occur when there are many (100's) NetworkObjects spawned and the application instance is exited (or you exit play mode in the editor).
* style
removing auto-added namespace
* test
Updating WhenManyObjectsAreSpawnedAtOnce_AllAreReceived test as it was not using the right logic to validate all NetworkObjects had been spawned.
Adding WhenManyObjectsAreSpawnedDuringSynchronization_AllAreReceived to validate this PR.
* update
adding changelog entry
* test
Migrating WhenManyObjectsAreSpawnedDuringSynchronization_AllAreReceived to SpawnNetworkObjectsDuringSynchronizationTest.SpawnNetworkObjectsDuringSynchronization.
* fix
Scenes loaded in single mode, after a client is connected, will defer CreateObjectMessage driven spawning until the scene loading event is completed. Consolidated the logic into a single method.
Added two new SceneEventProgress enums to be returned when a client attempts to load or unload a scene using NetworkSceneManager or any instance type tries to use the NetworkSceneManager when scene management is disabled (as opposed to throwing an exception it just logs a warning and returns the relative SceneEventProgress value).
* test
Made modifications due to SceneEventProgress adjustments.
Renamed SpawnNetworkObjectsDuringSynchronizationTest to SpawnNetworkObjectsDuringSceneEventsTest and migrated it to the test project tests runtime NetworkSceneManager folder.
Added an additional
* update
Updated the change log entry.
* style
removing unused namespace.
* Update CHANGELOG.md
* Update CHANGELOG.md
Fixing bad changelog merge
* Update SceneEventProgress.cs
Fixing the issue with the enum changes breaking the InternalNetcodeError value
* Update SceneEventProgress.cs
* update
Made adjustments based on PR review suggestions.
Added additional changelog entries to better reflect the PR.
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,9 +10,13 @@ Additional documentation and release notes are available at [Multiplayer Documen
10
10
11
11
### Added
12
12
13
+
- Added `SceneEventProgress.SceneManagementNotEnabled` return status to be returned when a `NetworkSceneManager` method is invoked and scene management is not enabled. (#2735)
14
+
- Added `SceneEventProgress.ServerOnlyAction` return status to be returned when a `NetworkSceneManager` method is invoked by a client. (#2735)
15
+
13
16
### Fixed
14
17
15
18
- Fixed a bug where having a class with Rpcs that inherits from a class without Rpcs that inherits from NetworkVariable would cause a compile error. (#2751)
19
+
- Fixed issue where during client synchronization and scene loading, when client synchronization or the scene loading mode are set to `LoadSceneMode.Single`, a `CreateObjectMessage` could be received, processed, and the resultant spawned `NetworkObject` could be instantiated in the client's currently active scene that could, towards the end of the client synchronization or loading process, be unloaded and cause the newly created `NetworkObject` to be destroyed (and throw and exception). (#2735)
16
20
- Fixed issue where `NetworkBehaviour.Synchronize` was not truncating the write buffer if nothing was serialized during `NetworkBehaviour.OnSynchronize` causing an additional 6 bytes to be written per `NetworkBehaviour` component instance. (#2749)
17
21
- Fixed issue where a parented in-scene placed NetworkObject would be destroyed upon a client or server exiting a network session but not unloading the original scene in which the NetworkObject was placed. (#2737)
18
22
- Fixed issue where during client synchronization and scene loading, when client synchronization or the scene loading mode are set to `LoadSceneMode.Single`, a `CreateObjectMessage` could be received, processed, and the resultant spawned `NetworkObject` could be instantiated in the client's currently active scene that could, towards the end of the client synchronization or loading process, be unloaded and cause the newly created `NetworkObject` to be destroyed (and throw and exception). (#2735)
@@ -21,6 +25,8 @@ Additional documentation and release notes are available at [Multiplayer Documen
21
25
### Changed
22
26
- Changed `NetworkTransform` authoritative instance tick registration so a single `NetworkTransform` specific tick event update will update all authoritative instances to improve perofmance. (#2713)
23
27
28
+
- Changed `NetworkSceneManager` to return a `SceneEventProgress` status and not throw exceptions for methods invoked when scene management is disabled and when a client attempts to access a `NetworkSceneManager` method by a client. (#2735)
thrownewNotServerException("Only server can start a scene event!");
1016
+
Debug.LogWarning($"{nameof(LoadScene)} was called, but {nameof(NetworkConfig.EnableSceneManagement)} was not enabled! Enable {nameof(NetworkConfig.EnableSceneManagement)} prior to starting a client, host, or server prior to using {nameof(NetworkSceneManager)}!");
thrownewNotServerException("Only server can start a scene event!");
1044
+
Debug.LogWarning($"{nameof(LoadScene)} was called, but {nameof(NetworkConfig.EnableSceneManagement)} was not enabled! Enable {nameof(NetworkConfig.EnableSceneManagement)} prior to starting a client, host, or server prior to using {nameof(NetworkSceneManager)}!");
0 commit comments