Skip to content

Commit 7d53561

Browse files
Merge branch 'develop-3.x.x' into chore/merge-3-2-1-into-develop-3-x-x
2 parents c8f0f75 + 2676f2b commit 7d53561

30 files changed

Lines changed: 1228 additions & 213 deletions

‎com.unity.netcode.gameobjects/CHANGELOG.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@ Additional documentation and release notes are available at [Multiplayer Documen
1616

1717
### Added
1818

19+
### Changed
20+
21+
### Deprecated
22+
23+
### Removed
24+
25+
### Fixed
26+
27+
- Issue where `NetworkAnimator` logged an error for a trigger-conditioned transition into an Exit node, and a client that joined during that transition, or during one into a sub-state machine, did not synchronize with it. Transitions that pass through Exit, Entry or sub-state machine nodes now resolve to the state they reach, and a late-joining client cross-fades from the matching originating state when several states transition into the same destination. (#4238)
28+
- Ensured all callbacks are wrapped with exception handling to avoid silent errors. (#4161)
29+
30+
### Security
31+
32+
### Obsolete
33+
34+
## [3.2.0] - 2026-11-03
35+
36+
### Added
37+
1938
- Added Unity CLI commands (`netcode.gameobjects` groups) to set up NetworkManagers and network prefabs, start and stop sessions, inspect clients and spawned objects, spawn, despawn and change ownership, simulate network conditions and sample network traffic. They are available when the project has `com.unity.pipeline` 0.9.0-exp.1 or later. (#4210)
2039
- Added alignment of the Netcode for Entities tick rates with `NetworkConfig.TickRate` when a session carrying `GhostObject` prefabs is started, so `GhostObject` updates land on the same interval as the rest of Netcode for GameObjects. (#4144)
2140
- Added `NetworkConfig.AutoConfigureSnapshotSize`, enabled by default, which sets the Netcode for Entities snapshot packet size to 4096 bytes when a session carrying `GhostObject` prefabs is started. Netcode for Entities defaults to a single MTU, which updates `GhostObject`s well below the tick rate at the instance counts Netcode for GameObjects projects typically run. Disable it to manage the value yourself. (#4144)
@@ -31,6 +50,8 @@ Additional documentation and release notes are available at [Multiplayer Documen
3150

3251
### Fixed
3352

53+
- Issue where `NetworkTime` reported a `TickOffset` of almost a whole tick, instead of zero, for some times that land on a tick (for example 0.3 at a tick rate of 10), which put `TickWithPartial` one tick ahead or, in long sessions, `Tick` one tick behind. Times between minus one tick and zero now report tick -1 with a positive `TickOffset`, as other negative times do. (#4228)
54+
- Issue where bits written with `BitWriter` were lost when a later `BitWriter.TryBeginWriteBits` call in the same bitwise context grew the `FastBufferWriter`. The bytes written earlier in that context were replaced with zeros or uninitialized memory. (#4226)
3455
- Issue where a growable `FastBufferWriter` created with a size of 0 never returned from its first write or `TryBeginWrite` call that needed the buffer to grow. (#4224)
3556
- Issue where a `FastBufferReader` created with an offset and the default length of -1 read past the end of its source. The `ArraySegment<byte>` overload that takes an offset now applies it from the start of the segment. (#4222)
3657
- Issue where a client synchronized while a `NetworkList<T>` still had unsent changes applied those changes twice, resulting in duplicate entries and index-based events landing on the wrong elements on that client. (#4216)

‎com.unity.netcode.gameobjects/Runtime/Components/Helpers/ComponentController.cs‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,17 +396,21 @@ protected override void OnNetworkPostSpawn()
396396
}
397397

398398
/// <inheritdoc/>
399-
/// <remarks>
400-
/// If overriding this method, it is required that you invoke this base method.
401-
/// </remarks>
399+
// TODO: Not used anymore
402400
public override void OnDestroy()
401+
{
402+
base.OnDestroy();
403+
}
404+
405+
406+
internal override void InternalOnDestroy()
403407
{
404408
if (m_CoroutineObject.IsRunning)
405409
{
406410
StopCoroutine(m_CoroutineObject.Coroutine);
407411
m_CoroutineObject.IsRunning = false;
408412
}
409-
base.OnDestroy();
413+
base.InternalOnDestroy();
410414
}
411415

412416
/// <summary>

‎com.unity.netcode.gameobjects/Runtime/Components/Helpers/UnifiedBootstrap.cs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,16 @@ public override bool Initialize(string defaultWorldName)
115115
LastCreatedWorld = CreateLocalWorld("LocalWorld");
116116
}
117117

118-
OnInitialized?.Invoke();
118+
// Always wrap events that can invoke user script in a try-catch to assure any
119+
// proceeding script is still executed.
120+
try
121+
{
122+
OnInitialized?.Invoke();
123+
}
124+
catch (Exception ex)
125+
{
126+
Debug.LogException(ex);
127+
}
119128

120129
return true;
121130
}

‎com.unity.netcode.gameobjects/Runtime/Components/Helpers/UnifiedUpdateConnections.cs‎

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using Unity.Collections;
44
using Unity.Entities;
5+
using UnityEngine;
56

67
namespace Unity.Netcode.Components
78
{
@@ -69,7 +70,14 @@ protected override void OnUpdate()
6970

7071
foreach (var con in m_TempConnections)
7172
{
72-
NetworkManager.OnNetCodeDisconnect?.Invoke(con);
73+
try
74+
{
75+
NetworkManager.OnNetCodeDisconnect?.Invoke(con);
76+
}
77+
catch (System.Exception ex)
78+
{
79+
Debug.LogException(ex);
80+
}
7381
}
7482

7583
m_TempConnections.Clear();
@@ -101,7 +109,14 @@ protected override void OnUpdate()
101109
// Set the connection in-game
102110
commandBuffer.AddComponent<NetworkStreamInGame>(entry.Value.Entity);
103111
commandBuffer.AddComponent(entry.Value.Entity, new ConnectionState { NetworkId = entry.Value.NetworkId });
104-
NetworkManager.OnNetCodeConnect?.Invoke(entry.Value);
112+
try
113+
{
114+
NetworkManager.OnNetCodeConnect?.Invoke(entry.Value);
115+
}
116+
catch (System.Exception ex)
117+
{
118+
Debug.LogException(ex);
119+
}
105120
m_TempConnections.Add(entry.Value);
106121
}
107122
}
@@ -123,8 +138,14 @@ protected override void OnUpdate()
123138
foreach (var (networkId, entity) in SystemAPI.Query<NetworkId>().WithAll<ConnectionState>().WithEntityAccess())
124139
{
125140
commandBuffer.RemoveComponent<ConnectionState>(entity);
126-
NetworkManager.OnNetCodeDisconnect?.Invoke(new NetcodeConnection
127-
{ World = World, Entity = entity, NetworkId = networkId.Value });
141+
try
142+
{
143+
NetworkManager.OnNetCodeDisconnect?.Invoke(new NetcodeConnection { World = World, Entity = entity, NetworkId = networkId.Value });
144+
}
145+
catch (System.Exception ex)
146+
{
147+
Debug.LogException(ex);
148+
}
128149
}
129150
}
130151
commandBuffer.Playback(EntityManager);
@@ -139,7 +160,15 @@ protected override void OnDestroy()
139160
foreach (var (networkId, entity) in SystemAPI.Query<NetworkId>().WithEntityAccess())
140161
{
141162
commandBuffer.RemoveComponent<ConnectionState>(entity);
142-
NetworkManager.OnNetCodeDisconnect?.Invoke(new NetcodeConnection { World = World, Entity = entity, NetworkId = networkId.Value });
163+
164+
try
165+
{
166+
NetworkManager.OnNetCodeDisconnect?.Invoke(new NetcodeConnection { World = World, Entity = entity, NetworkId = networkId.Value });
167+
}
168+
catch (System.Exception ex)
169+
{
170+
Debug.LogException(ex);
171+
}
143172
}
144173
commandBuffer.Playback(EntityManager);
145174
base.OnDestroy();

0 commit comments

Comments
 (0)