Skip to content

Commit aa6ea10

Browse files
Merge branch 'develop-2.0.0' into experimental/v2-x-x/ngo-and-n4e
2 parents fb7d11a + 1abb9a6 commit aa6ea10

3 files changed

Lines changed: 46 additions & 40 deletions

File tree

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,28 @@ Additional documentation and release notes are available at [Multiplayer Documen
1010

1111
### Added
1212

13+
14+
### Changed
15+
16+
17+
### Deprecated
18+
19+
20+
### Removed
21+
22+
23+
### Fixed
24+
25+
26+
### Security
27+
28+
29+
### Obsolete
30+
31+
## [2.8.0] - 2025-12-08
32+
33+
### Added
34+
1335
- It is now possible to control which port clients will bind to using the `UnityTransport.ConnectionData.ClientBindPort` field. If not set, clients will bind to an ephemeral port (same as before this change). (#3764)
1436
- Added a flag to override command-line arguments (port and ip) in `SetConnectionData`. (#3760)
1537
- Added a command-line singleton to parse environment command-line arguments. (#3760)
@@ -18,18 +40,13 @@ Additional documentation and release notes are available at [Multiplayer Documen
1840

1941
### Changed
2042

43+
- Improve performance of `DestroyObjectMessage`. (#3801)
2144
- Improve performance of `CreateObjectMessage`. (#3800)
2245
- First pass of CoreCLR engine API changes. (#3799)
2346
- Changed when a server is disconnecting a client with a reason it now defers the complete transport disconnect sequence until the end of the frame after the server's transport has sent all pending outbound messages. (#3786)
2447
- Improve performance of `NetworkTransformState`. (#3770)
2548
- Changed NetworkAnimator to use the `RpcAttribute` along with the appropriate `SendTo` parameter. (#3586)
2649

27-
### Deprecated
28-
29-
30-
### Removed
31-
32-
3350
### Fixed
3451

3552
- Fixed issues with the "Client-server quickstart for Netcode for GameObjects" script having static methods and properties. (#3787)
@@ -40,12 +57,6 @@ Additional documentation and release notes are available at [Multiplayer Documen
4057
- Fixed issue where using the dedicated server package would override all attempts to change the port by code. (#3760)
4158
- Fixed issue with authority animator instance sending itself RPCs. (#3586)
4259

43-
### Security
44-
45-
46-
### Obsolete
47-
48-
4960
## [2.7.0] - 2025-10-27
5061

5162
### Added

com.unity.netcode.gameobjects/Runtime/Messaging/Messages/DestroyObjectMessage.cs

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,63 +13,53 @@ internal struct DestroyObjectMessage : INetworkMessage, INetworkSerializeByMemcp
1313

1414
public ulong NetworkObjectId;
1515

16-
private byte m_DestroyFlags;
17-
1816
internal int DeferredDespawnTick;
1917
// Temporary until we make this a list
2018
internal ulong TargetClientId;
2119

2220
internal bool IsDistributedAuthority;
2321

24-
internal bool IsTargetedDestroy
25-
{
26-
get => ByteUtility.GetBit(m_DestroyFlags, 0);
27-
28-
set => ByteUtility.SetBit(ref m_DestroyFlags, 0, value);
29-
}
30-
31-
private bool IsDeferredDespawn
32-
{
33-
get => ByteUtility.GetBit(m_DestroyFlags, 1);
22+
private const byte k_IsTargetedDestroy = 0x01;
23+
private const byte k_IsDeferredDespawn = 0x02;
24+
private const byte k_DestroyGameObject = 0x04;
3425

35-
set => ByteUtility.SetBit(ref m_DestroyFlags, 1, value);
36-
}
26+
internal bool IsTargetedDestroy;
3727

3828
/// <summary>
3929
/// Used to communicate whether to destroy the associated game object.
4030
/// Should be false if the object is InScenePlaced and true otherwise
4131
/// </summary>
42-
public bool DestroyGameObject
43-
{
44-
get => ByteUtility.GetBit(m_DestroyFlags, 2);
45-
46-
set => ByteUtility.SetBit(ref m_DestroyFlags, 2, value);
47-
}
32+
public bool DestroyGameObject;
4833

4934
public void Serialize(FastBufferWriter writer, int targetVersion)
5035
{
5136
// Set deferred despawn flag
52-
IsDeferredDespawn = DeferredDespawnTick > 0;
37+
var isDeferredDespawn = DeferredDespawnTick > 0;
38+
39+
byte bitset = 0x00;
40+
if (IsTargetedDestroy) { bitset |= k_IsTargetedDestroy; }
41+
if (isDeferredDespawn) { bitset |= k_IsDeferredDespawn; }
42+
if (DestroyGameObject) { bitset |= k_DestroyGameObject; }
5343

5444
BytePacker.WriteValueBitPacked(writer, NetworkObjectId);
5545

5646
if (IsDistributedAuthority)
5747
{
58-
writer.WriteByteSafe(m_DestroyFlags);
48+
writer.WriteByteSafe(bitset);
5949

6050
if (IsTargetedDestroy)
6151
{
6252
BytePacker.WriteValueBitPacked(writer, TargetClientId);
6353
}
6454

65-
if (targetVersion < k_OptimizeDestroyObjectMessage || IsDeferredDespawn)
55+
if (targetVersion < k_OptimizeDestroyObjectMessage || isDeferredDespawn)
6656
{
6757
BytePacker.WriteValueBitPacked(writer, DeferredDespawnTick);
6858
}
6959
}
7060
else if (targetVersion >= k_AllowDestroyGameInPlaced)
7161
{
72-
writer.WriteByteSafe(m_DestroyFlags);
62+
writer.WriteByteSafe(bitset);
7363
}
7464

7565
if (targetVersion < k_OptimizeDestroyObjectMessage)
@@ -89,20 +79,25 @@ public bool Deserialize(FastBufferReader reader, ref NetworkContext context, int
8979
ByteUnpacker.ReadValueBitPacked(reader, out NetworkObjectId);
9080
if (networkManager.DistributedAuthorityMode)
9181
{
92-
reader.ReadByteSafe(out m_DestroyFlags);
82+
reader.ReadByteSafe(out byte bitset);
83+
IsTargetedDestroy = (bitset & k_IsTargetedDestroy) != 0;
84+
var isDeferredDespawn = (bitset & k_IsDeferredDespawn) != 0;
85+
DestroyGameObject = (bitset & k_DestroyGameObject) != 0;
86+
9387
if (IsTargetedDestroy)
9488
{
9589
ByteUnpacker.ReadValueBitPacked(reader, out TargetClientId);
9690
}
9791

98-
if (receivedMessageVersion < k_OptimizeDestroyObjectMessage || IsDeferredDespawn)
92+
if (receivedMessageVersion < k_OptimizeDestroyObjectMessage || isDeferredDespawn)
9993
{
10094
ByteUnpacker.ReadValueBitPacked(reader, out DeferredDespawnTick);
10195
}
10296
}
10397
else if (receivedMessageVersion >= k_AllowDestroyGameInPlaced)
10498
{
105-
reader.ReadByteSafe(out m_DestroyFlags);
99+
reader.ReadByteSafe(out byte bitset);
100+
DestroyGameObject = (bitset & k_DestroyGameObject) != 0;
106101
}
107102

108103
if (receivedMessageVersion < k_OptimizeDestroyObjectMessage)

com.unity.netcode.gameobjects/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "com.unity.netcode.gameobjects",
33
"displayName": "Netcode for GameObjects",
44
"description": "Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.",
5-
"version": "2.8.0",
5+
"version": "2.8.1",
66
"unity": "6000.0",
77
"dependencies": {
88
"com.unity.nuget.mono-cecil": "1.11.4",

0 commit comments

Comments
 (0)