Skip to content

Commit 3ded452

Browse files
fix: reach the moved NetworkTime through an alias as well
The unified job failed to compile with two CS0104 on NetworkManager.LocalTime and ServerTime: 'NetworkTime' is ambiguous between Unity.Netcode.GameObjects.Timing.NetworkTime and Unity.NetCode.NetworkTime. This is a second, distinct mechanism from the one 6013f45 addressed, and the stub used there could not produce it. That stub modelled N4E after its casing correction, where the colliding names are members of the enclosing Unity.Netcode namespace and therefore win over any import. The N4E that the pinned editor actually bundles is still Unity.NetCode, so both names arrive as imports instead - Unity.NetCode alongside Unity.Netcode.GameObjects.Timing - and two imports offering the same simple name is an ambiguity rather than a silent rebind. Before the move NGO's own NetworkTime was a member of Unity.Netcode, which is why the two imports coexisted for as long as they did. The alias fixes both mechanisms, so this holds whichever casing is installed. NetworkTime and NetworkTimeSystem are the only two names at risk: they are the sole intersection between Runtime/Timing/ and what N4E declares, confirmed against the 6000.7.0a5 bundled package. Only NetworkManager.cs is affected, being the only file that imports both namespaces and names either type in a type position.
1 parent 9022abd commit 3ded452

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@
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.
27+
// Netcode for Entities declares NetworkTime and NetworkTimeSystem too, and reaching ours by the bare
28+
// name fails against either casing of their namespace. Under Unity.NetCode both arrive as imports and
29+
// the reference is CS0104 ambiguous; once that is corrected to Unity.Netcode they become members of
30+
// the enclosing namespace, which is searched ahead of any import, and the bare name silently binds to
31+
// theirs. An alias is the only spelling that survives both: IDE0001 rules out qualifying the name, and
32+
// an alias sharing it is ignored rather than applied.
33+
using GameObjectsNetworkTime = Unity.Netcode.GameObjects.Timing.NetworkTime;
3134
using GameObjectsNetworkTimeSystem = Unity.Netcode.GameObjects.Timing.NetworkTimeSystem;
3235

3336

@@ -877,12 +880,12 @@ public struct ConnectionApprovalRequest
877880
/// <summary>
878881
/// The local <see cref="NetworkTime"/>
879882
/// </summary>
880-
public NetworkTime LocalTime => NetworkTickSystem?.LocalTime ?? default;
883+
public GameObjectsNetworkTime LocalTime => NetworkTickSystem?.LocalTime ?? default;
881884

882885
/// <summary>
883886
/// The <see cref="NetworkTime"/> on the server
884887
/// </summary>
885-
public NetworkTime ServerTime => NetworkTickSystem?.ServerTime ?? default;
888+
public GameObjectsNetworkTime ServerTime => NetworkTickSystem?.ServerTime ?? default;
886889

887890
/// <summary>
888891
/// Gets or sets if the application should be set to run in background

0 commit comments

Comments
 (0)