Skip to content

Commit 39c999c

Browse files
Merge branch 'develop-2.0.0' into feat/attachable-networkbehaviour-and-object-controller
2 parents ea66904 + f4b6cd4 commit 39c999c

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

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

1111
### Added
1212

13+
- Added `AsNativeArray()` read‑only accessor to `NetworkList<T>` (#3567)
1314

1415
### Fixed
1516

@@ -34,6 +35,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
3435

3536
### Fixed
3637

38+
- Removed allocation to the heap in NetworkBehaviourUpdate. (#3573)
3739
- Fixed issue where NetworkConfig.ConnectionData could cause the ConnectionRequestMessage to exceed the transport's MTU size and would result in a buffer overflow error. (#3564)
3840
- Fixed regression issue in v2.x where `NetworkObject.GetNetworkBehaviourAtOrderIndex` was converted from public to internal. (#3541)
3941
- Fixed ensuring OnValueChanged callback is still triggered on the authority when a collection changes and then reverts to the previous value in the same frame. (#3539)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ internal void NetworkBehaviourUpdate(bool forceSend = false)
3434
#endif
3535
try
3636
{
37-
m_DirtyNetworkObjects.UnionWith(m_PendingDirtyNetworkObjects);
37+
foreach (var dirtyNetworkObject in m_PendingDirtyNetworkObjects)
38+
{
39+
m_DirtyNetworkObjects.Add(dirtyNetworkObject);
40+
}
3841
m_PendingDirtyNetworkObjects.Clear();
3942

4043
// NetworkObject references can become null, when hidden or despawned. Once NUll, there is no point

com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,24 @@ public T this[int index]
631631
}
632632
}
633633

634+
/// <summary>
635+
/// Gets a **zero‑allocation**, <see cref="NativeArray{T}.ReadOnly"/> view over the current
636+
/// elements of this <see cref="NetworkList{T}"/>.
637+
/// </summary>
638+
/// <remarks>
639+
/// The returned array stays valid **only until** the list is mutated (add, remove,
640+
/// clear, resize) or <see cref="Dispose()"/> is called on the container. Continuing to use
641+
/// the array after it is invalid will result in undefined behaviour;
642+
/// callers are responsible for ensuring a safe lifetime.
643+
/// </remarks>
644+
/// <returns>
645+
/// A <see cref="NativeArray{T}.ReadOnly"/> reference that shares the same backing memory as this list.
646+
/// </returns>
647+
public NativeArray<T>.ReadOnly AsNativeArray()
648+
{
649+
return m_List.AsReadOnly();
650+
}
651+
634652
private void HandleAddListEvent(NetworkListEvent<T> listEvent)
635653
{
636654
m_DirtyEvents.Add(listEvent);

0 commit comments

Comments
 (0)