Skip to content

Commit 6013f45

Browse files
fix: reach the moved NetworkTimeSystem through an alias
Netcode for Entities 6.7.0 corrected the casing of its namespace, so it now declares Unity.Netcode.NetworkTimeSystem. The enclosing namespace is searched ahead of any using directive, so once the timing types leave Unity.Netcode the five files that still spell the name bare bind to theirs instead, and Unity.Netcode.Runtime stops compiling in any project that has both packages: 16 errors across 6 files, all of them cascading from the NetworkManager.NetworkTimeSystem property picking up the wrong type. The collision stub is corrected to match what N4E actually shipped. It sub-namespaced NetworkTime into Unity.Netcode.NetcodeTime but left NetworkTimeSystem in the shared root, so only that one name is occupied.
1 parent b446914 commit 6013f45

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

‎apiupdaterproject/Assets/CollisionStub~/N4ECollisionStub.cs‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
// Stands in for a second package occupying Unity.Netcode.NetworkTime and
2-
// Unity.Netcode.NetworkTimeSystem, which is what Netcode for Entities does once the casing of its
3-
// Unity.NetCode namespace is corrected.
1+
// Stands in for a second package occupying Unity.Netcode.NetworkTimeSystem, which is what Netcode
2+
// for Entities does as of 6.7.0: its casing correction moved 204 files into Unity.Netcode, and it
3+
// sub-namespaced NetworkTime into Unity.Netcode.NetcodeTime but left NetworkTimeSystem behind.
44
//
5-
// Only those two names collide. NetworkTickSystem deliberately is not declared here, so a
6-
// --collision-stub run asserts both halves of the finding in one pass: the updater migrates
7-
// NetworkTickSystem, and it cannot migrate the two whose old names still resolve.
5+
// Only that one name collides. NetworkTime and NetworkTickSystem deliberately are not declared here,
6+
// so a --collision-stub run asserts both halves of the finding in one pass: those two migrate, and
7+
// the one whose old name still resolves cannot.
88
//
99
// Inert until run_upgrade_test.py --collision-stub copies this folder into place. Unity does not
1010
// import a directory whose name ends in '~'.
1111
namespace Unity.Netcode
1212
{
13-
public struct NetworkTime
14-
{
15-
public int ServerTick;
16-
}
17-
1813
public class NetworkTimeSystem
1914
{
2015
public uint EffectiveInputLatencyTicks;

‎apiupdaterproject/run_upgrade_test.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
reference under Assets/Editor and Assets/Runtime was rewritten and that no stale reference
99
survived. The 2.x sources are restored on exit so the test can be re-run.
1010
11-
With --collision-stub, a stub assembly is added that occupies Unity.Netcode.NetworkTime and
12-
Unity.Netcode.NetworkTimeSystem, standing in for a second package that has taken those names. The
13-
expectation then inverts for exactly those two: the updater is driven by resolution failure, so a
11+
With --collision-stub, a stub assembly is added that occupies Unity.Netcode.NetworkTimeSystem,
12+
standing in for Netcode for Entities, which still declares that name in the shared root namespace.
13+
The expectation then inverts for exactly that one: the updater is driven by resolution failure, so a
1414
name another assembly still resolves never reaches the MovedFrom data and cannot be migrated.
15-
NetworkTickSystem is deliberately absent from the stub and must still migrate, which is what makes
16-
the run prove both halves rather than merely fail.
15+
NetworkTime and NetworkTickSystem are deliberately absent from the stub and must still migrate, which
16+
is what makes the run prove both halves rather than merely fail.
1717
1818
Note that this script can be run from anywhere; paths are resolved relative to the script itself.
1919
"""
@@ -70,7 +70,7 @@
7070

7171
# The names the --collision-stub assembly occupies; under it these must NOT be rewritten.
7272
# Keep in sync with Assets/CollisionStub~/N4ECollisionStub.cs.
73-
STUB_OCCUPIED = ['Unity.Netcode.NetworkTime', 'Unity.Netcode.NetworkTimeSystem']
73+
STUB_OCCUPIED = ['Unity.Netcode.NetworkTimeSystem']
7474

7575

7676
def expected_pairs():

‎com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
using PackageInfo = UnityEditor.PackageManager.PackageInfo;
2525
#endif
2626
using UnityEngine.SceneManagement;
27+
// Netcode for Entities also declares Unity.Netcode.NetworkTimeSystem. The enclosing namespace is
28+
// searched before any using directive, so inside Unity.Netcode the bare name binds to theirs and the
29+
// import above is never consulted. An alias is the only spelling that reaches ours from here, since
30+
// IDE0001 rules out qualifying the name and an alias sharing it is silently ignored.
31+
using GameObjectsNetworkTimeSystem = Unity.Netcode.GameObjects.Timing.NetworkTimeSystem;
2732

2833

2934

@@ -1017,7 +1022,7 @@ public NetworkPrefabHandler PrefabHandler
10171022
/// Accessor property for the <see cref="NetworkTimeSystem"/> of the NetworkManager.
10181023
/// Prefer the use of the LocalTime and ServerTime properties
10191024
/// </summary>
1020-
public NetworkTimeSystem NetworkTimeSystem { get; private set; }
1025+
public GameObjectsNetworkTimeSystem NetworkTimeSystem { get; private set; }
10211026

10221027
/// <summary>
10231028
/// Accessor property for the <see cref="NetworkTickSystem"/> of the NetworkManager.
@@ -1310,7 +1315,7 @@ internal void Initialize(bool server)
13101315
ConnectionManager.Initialize(this);
13111316

13121317
// The remaining systems can then be initialized
1313-
NetworkTimeSystem = server ? NetworkTimeSystem.ServerTimeSystem() : new NetworkTimeSystem(1.0 / NetworkConfig.TickRate);
1318+
NetworkTimeSystem = server ? GameObjectsNetworkTimeSystem.ServerTimeSystem() : new GameObjectsNetworkTimeSystem(1.0 / NetworkConfig.TickRate);
13141319
NetworkTickSystem = NetworkTimeSystem.Initialize(this);
13151320
AnticipationSystem = new AnticipationSystem(this);
13161321

0 commit comments

Comments
 (0)