From 0d80039041d477f9865f5f9f65c601eb8c708a67 Mon Sep 17 00:00:00 2001 From: Yuto Harada Date: Wed, 6 Aug 2025 16:44:47 +0900 Subject: [PATCH 1/2] perf(networked-vars): Skip NetworkList set operation when value unchanged Added equality check in NetworkList indexer setter to avoid unnecessary operations when the new value equals the existing value. This improves performance by preventing redundant list events and network synchronization. --- .../Runtime/NetworkVariable/Collections/NetworkList.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs index 9f0382c26a..e47b92e9b2 100644 --- a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs +++ b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs @@ -617,6 +617,13 @@ public T this[int index] } var previousValue = m_List[index]; + + // Compare the Value being applied to the current value + if (NetworkVariableSerialization.AreEqual(ref previousValue, ref value)) + { + return; + } + m_List[index] = value; var listEvent = new NetworkListEvent() From d2ed595a65f6e6d68bf69627b2026227a23adda2 Mon Sep 17 00:00:00 2001 From: Yuto Harada Date: Wed, 6 Aug 2025 16:47:47 +0900 Subject: [PATCH 2/2] docs: Add CHANGELOG entry for NetworkList optimization (#????) --- com.unity.netcode.gameobjects/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index ce3051ca2e..0c77b0e77c 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -19,6 +19,8 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Changed +- Optimized `NetworkList` indexer setter to skip operations when the new value equals the existing value, improving performance by avoiding unnecessary list events and network synchronization. (#????) + ## [2.5.0] - 2025-08-01