Skip to content

Commit c78f679

Browse files
chore: netcode for entities 7.0.0 as a dependency, unified api behind a define
N4E becomes a hard dependency at 7.0.0, and com.unity.transport moves to 6.5.0 to match it. N4E 7.0.0 ships its unified API - GhostObject, GhostBehaviour, GhostField - behind NETCODE_GAMEOBJECT_BRIDGE_EXPERIMENTAL, which leaves those types internal in the configuration NGO ships. A public type cannot derive from an internal one, so the unified path can no longer key off the package being present: the UNIFIED_NETCODE versionDefine is removed from the four assembly definitions and the symbol is set by the project instead, alongside N4E's own define. NetworkObjectBridge is internal for the same reason, and UnifiedBootstrap raises an #error when only one of the two defines is set. With N4E present the two packages share the Unity.Netcode namespace, which breaks three things outside the unified gates: - N4E's Netcode facade type shadows the namespace, so 22 XML doc crefs and one nameof that qualified with Netcode. stopped resolving. - N4E declares an INetworkStreamDriverConstructor in the shared root that the enclosing namespace finds ahead of NGO's, so the one implementation in the editor tests is fully qualified. - N4E's source generator errors on an assembly that does not reference N4E, so the editor test assembly now references it. Multiplayer Services 2.3.1 does not compile against N4E 7.0.0 and no fix is published, so it is dropped from the test project manifests. Validation moves to trunk, the only editor that has dropped N4E as a core package and can resolve the 7.0.0 request rather than its bundled 6.7.0. The unified work is preserved and still compiles with both defines set: the N4E 6.7.0 spellings are updated, and GhostObject.ApplyPostTransformMatrixScale, which N4E removed in its scale rework, is reimplemented over the new PostTransformMatrix model. The unified CI job sets the defines itself and is no longer a PR check. Also disables the serialization tests that fail under CoreCLR so the package is not ejected from the editor manifest batch. Parts of this are taken from #4156.
1 parent 9fda16e commit c78f679

29 files changed

Lines changed: 129 additions & 91 deletions

.yamato/_triggers.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ pr_code_changes_checks:
9090
# Note that our daily tests will anyway run both test configurations in "minimal supported" and "trunk" configurations
9191
- .yamato/desktop-standalone-tests.yml#desktop_standalone_test_testproject_ubuntu_il2cpp_{{ pinnedTrunk }}
9292
- .yamato/cmb-service-standalone-tests.yml#cmb_service_standalone_test_testproject_ubuntu_il2cpp_{{ pinnedTrunk }}
93-
- .yamato/_run-all.yml#run_all_unified_tests
93+
# The unified (NGO + N4E) tests are no longer a PR check: the unified API is behind N4E's own
94+
# experimental define, so it is not part of what NGO ships. Still run nightly and on "/ci unified".
9495
# Run code coverage test (PRs use the pinned "safe" trunk)
9596
- .yamato/code-coverage.yml#code_coverage_project_test_testproject_ubuntu_{{ pinnedTrunk }}
9697
triggers:

.yamato/project.metafile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,19 @@ test_platforms:
175175
# Editors to be used for testing. NGOv3.X official support started from 6000.7 editor
176176
# TODO: When a new editor will be released it should be added to this list
177177

178+
# TEMPORARY: only trunk has dropped Netcode for Entities as a core package, so only there does the
179+
# com.unity.netcode 7.0.0 dependency resolve - a released editor's bundled 6.7.0 wins over the request.
180+
# Restore the released editors here once one ships without it. `all` is left alone as the reminder.
178181
validation_editors:
179182
default:
180-
- 6000.7
183+
- trunk
181184
all:
182185
- 6000.7.0a6
183186
- 6000.7
184187
- trunk
185188
- 1d47644d0e359a8139ae6f99217da3c4e47f4779
186189
minimal:
187-
- 6000.7.0a6
190+
- trunk
188191
pinnedTrunk: 1d47644d0e359a8139ae6f99217da3c4e47f4779
189192

190193

.yamato/unified-tests.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
# 2. For all unified editors (currently a single pinned alpha, see project.metafile)
1111

1212
# QUALITY CONSIDERATIONS--------------------------------------------------------------------
13-
# TODO: the manifest swap means testproject/Packages/manifest-unified.json has to be kept in sync
14-
# with manifest.json by hand. Revisit once N4E is a hard dependency of NGO and one manifest
15-
# can cover both cases.
13+
# TODO: N4E is now a hard dependency, so the manifest swap only pins the N4E version and the two
14+
# manifests can be collapsed into one.
15+
# This job is deliberately not part of the PR checks: N4E 7.0.0 ships the unified API behind its own
16+
# experimental define, so nothing in the shipping configuration compiles it.
1617

1718
#------------------------------------------------------------------------------------
1819

@@ -36,9 +37,11 @@ unified_test_{{ project.name }}_{{ platform.name }}_{{ editor }}:
3637
UNIFIED_TESTS: "true"
3738

3839
commands:
39-
# Swap in the manifest that has the unified packages and versions required.
40-
# Without the N4E package, UNIFIED_NETCODE is undefined and the unified API excluded.
40+
# Swap in the manifest that pins the N4E version the unified API is written against.
4141
- cp {{ project.path }}/Packages/manifest-unified.json {{ project.path }}/Packages/manifest.json
42+
# Turn the unified API on. UNIFIED_NETCODE is opt-in, and N4E keeps its GameObject bridge internal
43+
# until NETCODE_GAMEOBJECT_BRIDGE_EXPERIMENTAL is defined, so both are needed here and nowhere else.
44+
- sed -i "s/UNITY_NETCODE_NATIVE_COLLECTION_SUPPORT/UNITY_NETCODE_NATIVE_COLLECTION_SUPPORT;NETCODE_GAMEOBJECT_BRIDGE_EXPERIMENTAL;UNIFIED_NETCODE;OUT_OF_BAND_RPC/" {{ project.path }}/ProjectSettings/ProjectSettings.asset
4245
- unity-downloader-cli --fast --wait -u {{ editor }} -c Editor
4346
- UnifiedTestRunner --testproject={{ project.path }} --suite=playmode --artifacts-path=test-results --editor-location=.Editor --rerun-strategy=Test --retry={{ num_test_retries }} --clean-library-on-rerun --timeout={{ test_timeout }}
4447
artifacts:

com.unity.netcode.gameobjects/CHANGELOG.md

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

1111
### Added
1212

13+
- Netcode for Entities (`com.unity.netcode` 7.0.0) is now a dependency, so installing Netcode for GameObjects also brings it, and its own dependencies (Entities, Burst, Collections), into the project.
14+
1315
### Changed
1416

17+
- The `com.unity.transport` dependency moved from 2.6.0 to 6.5.0, the version Netcode for Entities 7.0.0 requires.
18+
1519
- Changed `NetworkTransform.UseHalfFloatPrecision` to synchronize position with a resolution of approximately 1mm regardless of how far an object has travelled. Previously the resolution could degrade to approximately 3cm. This does not increase bandwidth, but projects using `NetworkTransform.UseUnreliableDeltas` will send full precision position updates more often. (#4129)
1620

1721
- All editor assembly definitions are renamed with `Unity.Netcode.GameObjects.x` variants

com.unity.netcode.gameobjects/Editor/NetworkObjectEditor.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Collections.Generic;
22
#if UNIFIED_NETCODE
3-
using Unity.NetCode;
4-
using Unity.NetCode.Editor;
3+
using Unity.Netcode.Editor;
54
#endif
65
using UnityEditor;
76
using UnityEngine;

com.unity.netcode.gameobjects/Editor/Unity.Netcode.Editor.asmdef

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@
4646
"expression": "0.2.0",
4747
"define": "MULTIPLAYER_SERVICES_SDK_INSTALLED"
4848
},
49-
{
50-
"name": "com.unity.netcode",
51-
"expression": "1.10.1",
52-
"define": "UNIFIED_NETCODE"
53-
},
5449
{
5550
"name": "com.unity.multiplayer.playmode",
5651
"expression": "0.1.0",

com.unity.netcode.gameobjects/Runtime/Components/AnticipatedNetworkTransform.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ namespace Unity.Netcode.Components
2121
/// resulting in a "snap" to the new value if it is different from the anticipated value.</description></item>
2222
///
2323
/// <item><description><b>Smooth:</b> In this mode (with <see cref="StaleDataHandling"/> set to
24-
/// <see cref="Netcode.StaleDataHandling.Ignore"/> and an <see cref="NetworkBehaviour.OnReanticipate"/> callback that calls
24+
/// <see cref="StaleDataHandling.Ignore"/> and an <see cref="NetworkBehaviour.OnReanticipate"/> callback that calls
2525
/// <see cref="Smooth"/> from the anticipated value to the authority value with an appropriate
2626
/// <see cref="Mathf.Lerp"/>-style smooth function), when a more up-to-date value is received from the authority,
2727
/// it will interpolate over time from an incorrect anticipated value to the correct authoritative value.</description></item>
2828
///
2929
/// <item><description><b>Constant Reanticipation:</b> In this mode (with <see cref="StaleDataHandling"/> set to
30-
/// <see cref="Netcode.StaleDataHandling.Reanticipate"/> and an <see cref="NetworkBehaviour.OnReanticipate"/> that calculates a
30+
/// <see cref="StaleDataHandling.Reanticipate"/> and an <see cref="NetworkBehaviour.OnReanticipate"/> that calculates a
3131
/// new anticipated value based on the current authoritative value), when a more up-to-date value is received from
3232
/// the authority, user code calculates a new anticipated value, possibly calling <see cref="Smooth"/> to interpolate
3333
/// between the previous anticipation and the new anticipation. This is useful for values that change frequently and
@@ -101,11 +101,11 @@ private void Reset()
101101
/// Defines what the behavior should be if we receive a value from the server with an earlier associated
102102
/// time value than the anticipation time value.
103103
/// <br/><br/>
104-
/// If this is <see cref="Netcode.StaleDataHandling.Ignore"/>, the stale data will be ignored and the authoritative
104+
/// If this is <see cref="StaleDataHandling.Ignore"/>, the stale data will be ignored and the authoritative
105105
/// value will not replace the anticipated value until the anticipation time is reached. <see cref="OnAuthoritativeValueChanged"/>
106106
/// and <see cref="OnReanticipate"/> will also not be invoked for this stale data.
107107
/// <br/><br/>
108-
/// If this is <see cref="Netcode.StaleDataHandling.Reanticipate"/>, the stale data will replace the anticipated data and
108+
/// If this is <see cref="StaleDataHandling.Reanticipate"/>, the stale data will replace the anticipated data and
109109
/// <see cref="OnAuthoritativeValueChanged"/> and <see cref="OnReanticipate"/> will be invoked.
110110
/// In this case, the authoritativeTime value passed to <see cref="OnReanticipate"/> will be lower than
111111
/// the anticipationTime value, and that callback can be used to calculate a new anticipated value.

com.unity.netcode.gameobjects/Runtime/Components/Helpers/NetworkObjectBridge.cs

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#if UNIFIED_NETCODE
2-
using Unity.NetCode;
2+
using Unity.Mathematics;
3+
using Unity.Transforms;
34
using UnityEngine;
45

56
namespace Unity.Netcode
@@ -13,7 +14,9 @@ namespace Unity.Netcode
1314

1415
[DefaultExecutionOrder(GhostObject.ExecutionOrder + 1)]
1516
//BREAK --- Fix this on UNIFIED side 1st
16-
public partial class NetworkObjectBridge : GhostBehaviour
17+
// Internal: GhostBehaviour is only public when NETCODE_GAMEOBJECT_BRIDGE_EXPERIMENTAL is defined, and a public
18+
// type cannot derive from an internal one.
19+
internal partial class NetworkObjectBridge : GhostBehaviour
1720
{
1821
// DefaultExecutionOrder
1922
// TODO: Define a const for the value used on GhostObject and use that value
@@ -83,5 +86,42 @@ internal void ApplyScale(Vector3 scale)
8386
Ghost.ApplyPostTransformMatrixScale(scale);
8487
}
8588
}
89+
90+
/// <summary>
91+
/// Stands in for N4E's <c>GhostObject.ApplyPostTransformMatrixScale</c>, removed by the 6.7.0 non-uniform
92+
/// scale rework that gave the GameObject-to-entity transform sync ownership of the
93+
/// <see cref="PostTransformMatrix"/>. Remove this once N4E exposes a supported way to push scale to a ghost.
94+
/// </summary>
95+
internal static class GhostObjectScaleExtensions
96+
{
97+
/// <summary>
98+
/// A ghost that replicates 3D scale stores it in its <see cref="PostTransformMatrix"/> and holds
99+
/// <see cref="LocalTransform.Scale"/> at 1, because consumers multiply the two. A ghost authored with
100+
/// <c>UseUniformScale</c> has no matrix - and cannot gain one at runtime, since the component is only in the
101+
/// replicated set when the prefab is registered - so only the uniform scale can be applied there.
102+
/// </summary>
103+
internal static void ApplyPostTransformMatrixScale(this GhostObject ghost, Vector3 scale)
104+
{
105+
var entityManager = ghost.World.EntityManager;
106+
var entity = ghost.Entity;
107+
var localTransform = entityManager.GetComponentData<LocalTransform>(entity);
108+
109+
if (entityManager.HasComponent<PostTransformMatrix>(entity))
110+
{
111+
entityManager.SetComponentData(entity, new PostTransformMatrix { Value = float4x4.Scale(scale) });
112+
localTransform.Scale = 1f;
113+
}
114+
else
115+
{
116+
if (!Mathf.Approximately(scale.x, scale.y) || !Mathf.Approximately(scale.y, scale.z))
117+
{
118+
Debug.LogWarning($"[{nameof(NetworkObjectBridge)}] Non-uniform scale {scale} cannot be replicated by a ghost authored for uniform scale; applying {scale.x} to all axes.", ghost);
119+
}
120+
localTransform.Scale = scale.x;
121+
}
122+
123+
entityManager.SetComponentData(entity, localTransform);
124+
}
125+
}
86126
}
87127
#endif

com.unity.netcode.gameobjects/Runtime/Components/Helpers/UnifiedBootstrap.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
#if UNIFIED_NETCODE && !NETCODE_GAMEOBJECT_BRIDGE_EXPERIMENTAL
2+
#error UNIFIED_NETCODE also requires NETCODE_GAMEOBJECT_BRIDGE_EXPERIMENTAL: Netcode for Entities keeps its GameObject bridge (GhostObject, GhostBehaviour, GhostField) internal until that define is set.
3+
#endif
14
#if UNIFIED_NETCODE
25
using System;
36
using Unity.Entities;
4-
using Unity.NetCode;
57
using UnityEngine;
68

79
namespace Unity.Netcode

com.unity.netcode.gameobjects/Runtime/Components/Helpers/UnifiedUpdateConnections.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using Unity.Collections;
44
using Unity.Entities;
5-
using Unity.NetCode;
65
using UnityEngine;
76

87
namespace Unity.Netcode.Components

0 commit comments

Comments
 (0)