Skip to content

Commit dceef27

Browse files
Merge branch 'develop-3.x.x' into fix/rpc-pose-test-yield
2 parents 0777b2f + 281aef0 commit dceef27

5 files changed

Lines changed: 99 additions & 10 deletions

File tree

‎.yamato/wrench/preview-a-p-v.yml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ preview_apv_-_6000_7_-_macos13arm:
7575
UNITY_LICENSING_SERVER_DELETE_ULF: 0
7676
UNITY_LICENSING_SERVER_TOOLSET: pro
7777
UPMPVP_CONTEXT_WRENCH: 3.11.5.0
78-
WRENCH_LOCALAPV_URL: https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-3-24_1493dea1e0eb932938365a4a53ec2091ec007ceec57eea844d15a058eddedc9f.zip
78+
WRENCH_LOCALAPV_URL: https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-3-19_94a756eb601d84c127a989866172fdd530ec62aa5d9611a9c9898a625926ec62.zip
7979
metadata:
8080
Job Maintainers: '#rm-packageworks'
8181
Wrench: 3.11.5.0
@@ -134,7 +134,7 @@ preview_apv_-_6000_7_-_ubuntu2204:
134134
UNITY_LICENSING_SERVER_DELETE_ULF: 0
135135
UNITY_LICENSING_SERVER_TOOLSET: pro
136136
UPMPVP_CONTEXT_WRENCH: 3.11.5.0
137-
WRENCH_LOCALAPV_URL: https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-3-24_1493dea1e0eb932938365a4a53ec2091ec007ceec57eea844d15a058eddedc9f.zip
137+
WRENCH_LOCALAPV_URL: https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-3-19_94a756eb601d84c127a989866172fdd530ec62aa5d9611a9c9898a625926ec62.zip
138138
metadata:
139139
Job Maintainers: '#rm-packageworks'
140140
Wrench: 3.11.5.0
@@ -194,7 +194,7 @@ preview_apv_-_6000_7_-_win10:
194194
UNITY_LICENSING_SERVER_DELETE_ULF: 0
195195
UNITY_LICENSING_SERVER_TOOLSET: pro
196196
UPMPVP_CONTEXT_WRENCH: 3.11.5.0
197-
WRENCH_LOCALAPV_URL: https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-3-24_1493dea1e0eb932938365a4a53ec2091ec007ceec57eea844d15a058eddedc9f.zip
197+
WRENCH_LOCALAPV_URL: https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-3-19_94a756eb601d84c127a989866172fdd530ec62aa5d9611a9c9898a625926ec62.zip
198198
metadata:
199199
Job Maintainers: '#rm-packageworks'
200200
Wrench: 3.11.5.0
@@ -254,7 +254,7 @@ preview_apv_-_7000_0_-_macos13arm:
254254
UNITY_LICENSING_SERVER_DELETE_ULF: 0
255255
UNITY_LICENSING_SERVER_TOOLSET: pro
256256
UPMPVP_CONTEXT_WRENCH: 3.11.5.0
257-
WRENCH_LOCALAPV_URL: https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-3-24_1493dea1e0eb932938365a4a53ec2091ec007ceec57eea844d15a058eddedc9f.zip
257+
WRENCH_LOCALAPV_URL: https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-3-19_94a756eb601d84c127a989866172fdd530ec62aa5d9611a9c9898a625926ec62.zip
258258
metadata:
259259
Job Maintainers: '#rm-packageworks'
260260
Wrench: 3.11.5.0
@@ -313,7 +313,7 @@ preview_apv_-_7000_0_-_ubuntu2204:
313313
UNITY_LICENSING_SERVER_DELETE_ULF: 0
314314
UNITY_LICENSING_SERVER_TOOLSET: pro
315315
UPMPVP_CONTEXT_WRENCH: 3.11.5.0
316-
WRENCH_LOCALAPV_URL: https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-3-24_1493dea1e0eb932938365a4a53ec2091ec007ceec57eea844d15a058eddedc9f.zip
316+
WRENCH_LOCALAPV_URL: https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-3-19_94a756eb601d84c127a989866172fdd530ec62aa5d9611a9c9898a625926ec62.zip
317317
metadata:
318318
Job Maintainers: '#rm-packageworks'
319319
Wrench: 3.11.5.0
@@ -373,7 +373,7 @@ preview_apv_-_7000_0_-_win10:
373373
UNITY_LICENSING_SERVER_DELETE_ULF: 0
374374
UNITY_LICENSING_SERVER_TOOLSET: pro
375375
UPMPVP_CONTEXT_WRENCH: 3.11.5.0
376-
WRENCH_LOCALAPV_URL: https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-3-24_1493dea1e0eb932938365a4a53ec2091ec007ceec57eea844d15a058eddedc9f.zip
376+
WRENCH_LOCALAPV_URL: https://artifactory.prd.it.unity3d.com/artifactory/stevedore-unity-internal/wrench-localapv/1-3-19_94a756eb601d84c127a989866172fdd530ec62aa5d9611a9c9898a625926ec62.zip
377377
metadata:
378378
Job Maintainers: '#rm-packageworks'
379379
Wrench: 3.11.5.0

‎com.unity.netcode.gameobjects/CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,20 @@ Additional documentation and release notes are available at [Multiplayer Documen
1818

1919
### Fixed
2020

21+
- Ensured a useful and human readable error is logged when a NetworkVariable is trying to serialize a private or protected type. (#4239)
2122
- Issue where `NetworkAnimator` logged an error for a trigger-conditioned transition into an Exit node, and a client that joined during that transition, or during one into a sub-state machine, did not synchronize with it. Transitions that pass through Exit, Entry or sub-state machine nodes now resolve to the state they reach, and a late-joining client cross-fades from the matching originating state when several states transition into the same destination. (#4238)
2223
- Ensured all callbacks are wrapped with exception handling to avoid silent errors. (#4161)
2324

2425
### Security
2526

2627
### Obsolete
2728

29+
## [3.2.1] - 2026-11-05
30+
31+
### Changed
32+
33+
- Updated the upgrade guide that removes the note about the unified netcode being experimental.
34+
2835
## [3.2.0] - 2026-11-03
2936

3037
### Added

‎com.unity.netcode.gameobjects/Documentation~/upgrade-guide.md‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,17 @@ In version 3.x, `NetworkTransform.UseHalfFloatPrecision` synchronizes position a
116116

117117
In version 2.x, the `Lerp` and `SmoothDampening` interpolation types smooth by different amounts at different frame rates, because Netcode for GameObjects applies smoothing per frame instead of over time. Version 3.x applies smoothing over time, so results at 60 frames per second (fps) stay the same as in version 2.x, and results at other frame rates differ.
118118

119-
## Netcode for Entities integration
119+
## Unity netcode integration
120120

121-
> [!NOTE]
122-
> This integration is experimental, so it's not ready for production use. The features and documentation for this integration might change before it's verified for release.
121+
Version 3.x introduces the foundations of the Unity netcode unified GameObject layer. When you add both a `GhostObject` and `NetworkObject` component to a prefab it becomes a "hybrid" prefab. When a hybrid prefab is registered within a network prefab list that is assigned to your `NetworkManager` component, Netcode for GameObjects will enter into "hybrid mode" when starting or joining a new session. Standard `NetworkBehaviour`, `NetworkVariable`, and RPC workflows work the same as in version 2.x, with the exception that you can use both `NetworkBehaviour` and `GhostBehaviour` components (_with some limitations_).
122+
123+
## CoreCLR compilation changes
124+
125+
CoreCLR introduces a new compilation pipeline that changes some custom serialization generation.
126+
127+
### NetworkVariable serialization
123128

124-
Version 3.x introduces the foundations of the unified GameObject layer for Netcode for Entities, known as the hybrid prefab concept. Version 3.x doesn't enable this integration by default for standard GameObject workflows. Standard `NetworkBehaviour`, `NetworkVariable`, and RPC workflows work the same as in version 2.x.
129+
The Mono compilation pipeline was capable of generating serialization for private and protected types. With CoreCLR, this is no longer possible and will fail the compilation. Ensure any types used inside NetworkVariables in your project are declared as `public` or `internal`.
125130

126131
## Additional resources
127132

‎com.unity.netcode.gameobjects/Editor/CodeGen/CodeGenHelpers.cs‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,61 @@ public static bool HasInterface(this TypeReference typeReference, string interfa
208208
}
209209
}
210210

211+
/// <summary>
212+
/// Collects every type that assembly scoped code cannot access when it uses <paramref name="type"/>.
213+
/// This is each private or protected nested type in its nesting chain, or in the chain of its generic arguments.
214+
/// A protected internal type is only hidden when it is declared in an assembly whose internals <paramref name="consumer"/> cannot see.
215+
/// </summary>
216+
/// <param name="type">The type the generated code uses.</param>
217+
/// <param name="consumer">The assembly the generated code is emitted into.</param>
218+
/// <param name="hidden">Receives each inaccessible type, without duplicates.</param>
219+
public static void CollectTypesHiddenFromAssembly(this TypeReference type, AssemblyDefinition consumer, List<TypeDefinition> hidden)
220+
{
221+
if (type is GenericInstanceType genericInstance)
222+
{
223+
foreach (var argument in genericInstance.GenericArguments)
224+
{
225+
argument.CollectTypesHiddenFromAssembly(consumer, hidden);
226+
}
227+
}
228+
else if (type is TypeSpecification specification)
229+
{
230+
specification.ElementType.CollectTypesHiddenFromAssembly(consumer, hidden);
231+
return;
232+
}
233+
234+
for (var definition = type.Resolve(); definition != null && definition.IsNested; definition = definition.DeclaringType)
235+
{
236+
var isHidden = definition.IsNestedPrivate || definition.IsNestedFamily || definition.IsNestedFamilyAndAssembly ||
237+
(definition.IsNestedFamilyOrAssembly && !consumer.CanSeeInternalsOf(definition.Module.Assembly));
238+
if (isHidden && !hidden.Contains(definition))
239+
{
240+
hidden.Add(definition);
241+
}
242+
}
243+
}
244+
245+
/// <summary>
246+
/// Checks whether code in <paramref name="consumer"/> can access the internal members of <paramref name="owner"/>.
247+
/// </summary>
248+
/// <param name="consumer">The assembly that accesses the members.</param>
249+
/// <param name="owner">The assembly that declares the members.</param>
250+
/// <returns>True if both are the same assembly, or <paramref name="owner"/> grants <paramref name="consumer"/> InternalsVisibleTo.</returns>
251+
private static bool CanSeeInternalsOf(this AssemblyDefinition consumer, AssemblyDefinition owner)
252+
{
253+
if (owner.Name.Name == consumer.Name.Name)
254+
{
255+
return true;
256+
}
257+
258+
// InternalsVisibleTo takes "Name" or "Name, PublicKey=..."; only the simple name matters here.
259+
return owner.CustomAttributes.Any(attribute =>
260+
attribute.AttributeType.FullName == typeof(System.Runtime.CompilerServices.InternalsVisibleToAttribute).FullName &&
261+
attribute.ConstructorArguments.Count == 1 &&
262+
attribute.ConstructorArguments[0].Value is string friend &&
263+
friend.Split(',')[0].Trim() == consumer.Name.Name);
264+
}
265+
211266
/// <summary>
212267
/// Checks a generic method instantiation against the generic constraints of the method it instantiates.
213268
/// Mono does not enforce these on the calls codegen emits, but CoreCLR does, and it rejects the entire

‎com.unity.netcode.gameobjects/Editor/CodeGen/NetworkBehaviourILPP.cs‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,28 @@ private void CreateNetworkVariableTypeInitializers(AssemblyDefinition assembly,
437437
continue;
438438
}
439439

440+
// CoreCLR enforces member access on the generic calls emitted below; Mono does not.
441+
var hiddenTypes = new List<TypeDefinition>();
442+
type.CollectTypesHiddenFromAssembly(assembly, hiddenTypes);
443+
if (hiddenTypes.Count > 0)
444+
{
445+
// Use the target assembly's defines: a Mono editor can build a CoreCLR player.
446+
if (assemblyDefines.Contains("ENABLE_CORECLR"))
447+
{
448+
foreach (var hiddenType in hiddenTypes)
449+
{
450+
m_Diagnostics.AddError($"{type} cannot be used in a network variable - Cannot access the {hiddenType.Name} type to generate serialization as it is {(hiddenType.IsNestedPrivate ? "private" : "protected")}. To fix this, change the access modifier to internal or public.");
451+
}
452+
continue;
453+
}
454+
455+
// Log a warning in Mono so we can warn users who haven't yet switched their projects over.
456+
foreach (var hiddenType in hiddenTypes)
457+
{
458+
m_Diagnostics.AddWarning($"NetworkVariable serialization for {type.Name} will fail in CoreCLR! With CoreCLR generated code cannot access the {hiddenType.Name} type to generate serialization as it is {(hiddenType.IsNestedPrivate ? "private" : "protected")}. To fix this, change the access modifier to internal or public.");
459+
}
460+
}
461+
440462
if (serializeMethod != null)
441463
{
442464
instructions.Add(processor.Create(OpCodes.Call, m_MainModule.ImportReference(serializeMethod)));

0 commit comments

Comments
 (0)