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
* feat
This includes the changes to provide users with a way to synchronize NetworkBehaviours with custom data prior to their associated NetworkObject is spawned.
* fix and refactor
This updates NetworkTransform so that it will properly synchronize when placed on nested NetworkBehaviours (i.e. their GameObject has no NetworkObject component).
This also includes some fixes that allows for NetworkObjects to fail, NetworkVariables to fail, and NetworkBehaviour synchronization to fail without impacting the rest of the synchronization process.
Minor fix for in-scene placed parenting under a non-NetworkObject to prevent from being added to the orphaned child list.
* test
Renamed NetworkObjectSceneSerializationTests to NetworkObjectSynchronizationTests.
Added a more robust/wider range of tests, also added running host or server as well as added a basic OnSynchronize test.
Added integration test to validate nested network transforms synchronize properly with nested GameObjects' transforms.
Fixed an issue with late joined clients not registering all players in NetcodeIntegrationTest.
* test manual
This include a nested NetworkTransform manual test to visually validate the nested NetworkTransform update.
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/CHANGELOG.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,17 +9,23 @@ Additional documentation and release notes are available at [Multiplayer Documen
9
9
## [Unreleased]
10
10
11
11
### Added
12
+
13
+
- Added protected method `NetworkBehaviour.OnSynchronize` which is invoked during the initial `NetworkObject` synchronization process. This provides users the ability to include custom serialization information that will be applied to the `NetworkBehaviour` prior to the `NetworkObject` being spawned. (#2298)
12
14
- Added support for different versions of the SDK to talk to each other in circumstances where changes permit it. Starting with this version and into future versions, patch versions should be compatible as long as the minor version is the same. (#2290)
13
15
- Added `NetworkObject` auto-add helper and Multiplayer Tools install reminder settings to Project Settings. (#2285)
14
-
- Added `public string DisconnectReason` getter to `NetworkManager` and `string Reason` to `ConnectionApprovalResponse`. Allows connection approval to communicate back a reason. Also added `public void DisconnectClient(ulong clientId, string reason)` allowing setting a disconnection reason, when explicitly disconnecting a client.
16
+
- Added `public string DisconnectReason` getter to `NetworkManager` and `string Reason` to `ConnectionApprovalResponse`. Allows connection approval to communicate back a reason. Also added `public void DisconnectClient(ulong clientId, string reason)` allowing setting a disconnection reason, when explicitly disconnecting a client. (#2280)
15
17
16
18
### Changed
17
19
18
20
- Changed 3rd-party `XXHash` (32 & 64) implementation with an in-house reimplementation (#2310)
21
+
- When `NetworkConfig.EnsureNetworkVariableLengthSafety` is disabled `NetworkVariable` fields do not write the additional `ushort` size value (_which helps to reduce the total synchronization message size_), but when enabled it still writes the additional `ushort` value. (#2298)
19
22
- Optimized bandwidth usage by encoding most integer fields using variable-length encoding. (#2276)
20
23
21
24
### Fixed
22
25
26
+
- 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)
27
+
- Fixed issue where `NetworkObject`s that failed to instantiate could cause the entire synchronization pipeline to be disrupted/halted for a connecting client. (#2298)
28
+
- 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)
23
29
- Custom messages are now properly received by the local client when they're sent while running in host mode. (#2296)
24
30
- Fixed issue where the host would receive more than one event completed notification when loading or unloading a scene only when no clients were connected. (#2292)
25
31
- Fixed an issue in `UnityTransport` where an error would be logged if the 'Use Encryption' flag was enabled with a Relay configuration that used a secure protocol. (#2289)
// Get the writer to handle seeking and determining how many bytes were written
921
+
varwriter=serializer.GetFastBufferWriter();
922
+
// Save our position before we attempt to write anything so we can seek back to it (i.e. error occurs)
923
+
varpositionBeforeWrite=writer.Position;
924
+
writer.WriteValueSafe(NetworkBehaviourId);
925
+
926
+
// Save our position where we will write the final size being written so we can skip over it in the
927
+
// event an exception occurs when deserializing.
928
+
varsizePosition=writer.Position;
929
+
writer.WriteValueSafe((ushort)0);
930
+
931
+
// Save our position before synchronizing to determine how much was written
932
+
varpositionBeforeSynchronize=writer.Position;
933
+
varthrewException=false;
934
+
try
935
+
{
936
+
OnSynchronize(refserializer);
937
+
}
938
+
catch(Exceptionex)
939
+
{
940
+
threwException=true;
941
+
if(NetworkManager.LogLevel<=LogLevel.Normal)
942
+
{
943
+
NetworkLog.LogWarning($"{name} threw an exception during synchronization serialization, this {nameof(NetworkBehaviour)} is being skipped and will not be synchronized!");
// Save our position before we begin synchronization deserialization
975
+
varpositionBeforeSynchronize=reader.Position;
976
+
varsynchronizationError=false;
977
+
try
978
+
{
979
+
// Invoke synchronization
980
+
OnSynchronize(refserializer);
981
+
}
982
+
catch(Exceptionex)
983
+
{
984
+
if(NetworkManager.LogLevel<=LogLevel.Normal)
985
+
{
986
+
NetworkLog.LogWarning($"{name} threw an exception during synchronization deserialization, this {nameof(NetworkBehaviour)} is being skipped and will not be synchronized!");
NetworkLog.LogWarning($"{name} read {totalBytesRead} bytes but was expected to read {expectedBytesToRead} bytes during synchronization deserialization! This {nameof(NetworkBehaviour)} is being skipped and will not be synchronized!");
0 commit comments