From 110bc18501088e32e27236f6f469ba50401b04df Mon Sep 17 00:00:00 2001 From: Noel Stephens Date: Fri, 4 Sep 2026 12:40:59 -0500 Subject: [PATCH 1/2] chore: reference the Netcode for Entities assemblies by GUID Three asmdefs named "Unity.NetCode" and "Unity.NetCode.Editor" as strings. Unity silently drops an asmdef reference it cannot resolve, so renaming either assembly would make every UNIFIED_NETCODE code path fail to compile with nothing pointing at the cause. A GUID reference resolves to whichever asmdef asset carries that GUID regardless of the name inside it, which is how NGO's own editor assembly rename stayed transparent to projects referencing it. The GUIDs are read from the installed package's .asmdef.meta files, not derived: Unity.NetCode 953adc2a6b8b4e3c8df5b728bcd546e9 Unity.NetCode.Editor eb8cf780bf058694ebf7ec5cf5b8cfa3 Unity.Entities is left by name. It is not the assembly at risk of a rename, and converting it would add surface that cannot be checked here for no benefit. Not verified locally: confirming a GUID reference resolves needs an editor with both packages installed. Worth an import in a project that has Netcode for Entities before this is relied on - if a GUID is wrong the reference drops silently, which is the failure this is meant to prevent. --- .../Editor/Unity.Netcode.Editor.asmdef | 4 ++-- .../Runtime/Unity.Netcode.Runtime.asmdef | 2 +- .../Tests/Runtime/Unity.Netcode.Runtime.Tests.asmdef | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/com.unity.netcode.gameobjects/Editor/Unity.Netcode.Editor.asmdef b/com.unity.netcode.gameobjects/Editor/Unity.Netcode.Editor.asmdef index 9ef9dac45f..ca7c2e6e26 100644 --- a/com.unity.netcode.gameobjects/Editor/Unity.Netcode.Editor.asmdef +++ b/com.unity.netcode.gameobjects/Editor/Unity.Netcode.Editor.asmdef @@ -8,8 +8,8 @@ "Unity.Networking.Transport", "Unity.Services.Core", "Unity.Services.Authentication", - "Unity.NetCode", - "Unity.NetCode.Editor" + "GUID:953adc2a6b8b4e3c8df5b728bcd546e9", + "GUID:eb8cf780bf058694ebf7ec5cf5b8cfa3" ], "includePlatforms": [ "Editor" diff --git a/com.unity.netcode.gameobjects/Runtime/Unity.Netcode.Runtime.asmdef b/com.unity.netcode.gameobjects/Runtime/Unity.Netcode.Runtime.asmdef index 98a2cd6a29..6b32d4a1b2 100644 --- a/com.unity.netcode.gameobjects/Runtime/Unity.Netcode.Runtime.asmdef +++ b/com.unity.netcode.gameobjects/Runtime/Unity.Netcode.Runtime.asmdef @@ -14,7 +14,7 @@ "Unity.Collections", "Unity.Burst", "Unity.Mathematics", - "Unity.NetCode", + "GUID:953adc2a6b8b4e3c8df5b728bcd546e9", "Unity.Entities" ], "includePlatforms": [], diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/Unity.Netcode.Runtime.Tests.asmdef b/com.unity.netcode.gameobjects/Tests/Runtime/Unity.Netcode.Runtime.Tests.asmdef index a2799e4cca..23439b2540 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/Unity.Netcode.Runtime.Tests.asmdef +++ b/com.unity.netcode.gameobjects/Tests/Runtime/Unity.Netcode.Runtime.Tests.asmdef @@ -14,7 +14,7 @@ "Unity.Mathematics", "UnityEngine.TestRunner", "UnityEditor.TestRunner", - "Unity.NetCode", + "GUID:953adc2a6b8b4e3c8df5b728bcd546e9", "Unity.Entities" ], "includePlatforms": [], From eef6f9dac17e06280e59aacb53571a49f8f4c157 Mon Sep 17 00:00:00 2001 From: Noel Stephens Date: Fri, 4 Sep 2026 13:28:56 -0500 Subject: [PATCH 2/2] chore: rename the internal NetworkMetrics to ToolsNetworkMetrics The last of the three type names NGO and Netcode for Entities share. This one is internal, so no user sees it and it is not a compile error either way: a source-declared type beats an imported one, so NGO's own assembly would take its own and warn CS0436. But once the two namespaces converge the warning appears in our build log for a name nobody can act on from outside, and "Unity.Netcode holds no name that collides" is a simpler thing to be able to say than "two of the three". ToolsNetworkMetrics keeps the suffix, so it still reads as a pair with its sibling NullNetworkMetrics - the two INetworkMetrics implementations, one behind MULTIPLAYER_TOOLS and one not. Five sites in two files: the declaration, both constructors, the profiler marker and the single construction site. Everything else that reads NetworkMetrics is a property of that name on NetworkManager, NetworkMetricsManager or NetworkTransport, all typed INetworkMetrics and untouched. The profiler marker keeps its old string rather than following the rename. It is what shows up in the Profiler, and an internal rename is not a reason to move it, so nameof gives way to the literal with a comment saying why. Verified as far as this machine allows: runtime, editor and runtime tests all compile clean, which covers the #else branch. The renamed class is entirely inside #if MULTIPLAYER_TOOLS and the harness has no Unity.Multiplayer.Tools references, so that branch cannot be built here. A parse pass over the file with the define on reports only CS0246/CS0234 for the tools types and no structural error, which is what a class and constructor disagreeing on a name would produce. The define-on path still wants a real editor build before this is trusted. --- .../Runtime/Metrics/NetworkMetricsManager.cs | 2 +- .../{NetworkMetrics.cs => ToolsNetworkMetrics.cs} | 10 ++++++---- ...workMetrics.cs.meta => ToolsNetworkMetrics.cs.meta} | 0 3 files changed, 7 insertions(+), 5 deletions(-) rename com.unity.netcode.gameobjects/Runtime/Metrics/{NetworkMetrics.cs => ToolsNetworkMetrics.cs} (98%) rename com.unity.netcode.gameobjects/Runtime/Metrics/{NetworkMetrics.cs.meta => ToolsNetworkMetrics.cs.meta} (100%) diff --git a/com.unity.netcode.gameobjects/Runtime/Metrics/NetworkMetricsManager.cs b/com.unity.netcode.gameobjects/Runtime/Metrics/NetworkMetricsManager.cs index 2a137396f7..4af1d8def4 100644 --- a/com.unity.netcode.gameobjects/Runtime/Metrics/NetworkMetricsManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/Metrics/NetworkMetricsManager.cs @@ -27,7 +27,7 @@ public void Initialize(NetworkManager networkManager) if (NetworkMetrics == null) { #if MULTIPLAYER_TOOLS - NetworkMetrics = new NetworkMetrics(); + NetworkMetrics = new ToolsNetworkMetrics(); #else NetworkMetrics = new NullNetworkMetrics(); #endif diff --git a/com.unity.netcode.gameobjects/Runtime/Metrics/NetworkMetrics.cs b/com.unity.netcode.gameobjects/Runtime/Metrics/ToolsNetworkMetrics.cs similarity index 98% rename from com.unity.netcode.gameobjects/Runtime/Metrics/NetworkMetrics.cs rename to com.unity.netcode.gameobjects/Runtime/Metrics/ToolsNetworkMetrics.cs index 4bb7bb20a0..6aeba77c74 100644 --- a/com.unity.netcode.gameobjects/Runtime/Metrics/NetworkMetrics.cs +++ b/com.unity.netcode.gameobjects/Runtime/Metrics/ToolsNetworkMetrics.cs @@ -8,20 +8,22 @@ namespace Unity.Netcode { - internal class NetworkMetrics : INetworkMetrics + internal class ToolsNetworkMetrics : INetworkMetrics { private const ulong k_MaxMetricsPerFrame = 1000L; private static readonly Dictionary k_SceneEventTypeNames; private static readonly ProfilerMarker k_FrameDispatch; - static NetworkMetrics() + static ToolsNetworkMetrics() { k_SceneEventTypeNames = new Dictionary(); foreach (SceneEventType type in Enum.GetValues(typeof(SceneEventType))) { k_SceneEventTypeNames[(uint)type] = type.ToString(); } - k_FrameDispatch = new ProfilerMarker($"{nameof(NetworkMetrics)}.DispatchFrame"); + // Spelled out rather than nameof: this is the name shown in the Profiler, and it + // should not move because the implementing type was renamed. + k_FrameDispatch = new ProfilerMarker("NetworkMetrics.DispatchFrame"); } private static string GetSceneEventTypeName(uint typeCode) @@ -85,7 +87,7 @@ private static string GetSceneEventTypeName(uint typeCode) private ulong m_NumberOfMetricsThisFrame; - public NetworkMetrics() + public ToolsNetworkMetrics() { Dispatcher = new MetricDispatcherBuilder() .WithCounters(m_TransportBytesSent, m_TransportBytesReceived) diff --git a/com.unity.netcode.gameobjects/Runtime/Metrics/NetworkMetrics.cs.meta b/com.unity.netcode.gameobjects/Runtime/Metrics/ToolsNetworkMetrics.cs.meta similarity index 100% rename from com.unity.netcode.gameobjects/Runtime/Metrics/NetworkMetrics.cs.meta rename to com.unity.netcode.gameobjects/Runtime/Metrics/ToolsNetworkMetrics.cs.meta