Search Issue Tracker
Won't Fix
Won't Fix in 1.0.X
Votes
0
Found in [Package]
1.0.0-pre.6
Issue ID
NCCBUG-149
Regression
No
Recursive Nested Serialization does not work with NetworkVariables
Reproduction steps:
1. Open the attached "NonNullableError.zip" project
2. Observe the Console
Expected result: No "non-nullable" error
Actual result: "Assets/Test.cs(8,61): error CS8377: The type 'AbilityParam' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'T' in the generic type or method 'NetworkVariable<T>'" error
Reproducible with: 1.0.0-pre.6 (2020.3.32f1, 2021.2.17f1, 2022.1.0b13, 2022.2.0a9)
Could not test with: 2019.4.37f1 (Netcode packages not supported), below 1.0.0-pre.6 (QosType and ConnectionConfig not found package script errors)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- D3D12 MainLight Shadowmap clear incorrectly when using UWP
- Crash on ShaderPropertySheet::SetTexture when changing color space on a specific project
- "ENABLE_INPUT_SYSTEM" flag is true even when the "InputSystem" package isn't installed
- The "ModifiableContactPair.IgnoreContact" method does not work
- Tooltips are shown in the random place when there is not enough space for it above the element
Resolution Note:
There are no fixes planned for this Bug
Resolution Note (1.0.X):
Hi,
As the error indicates, NetworkVariable doesn't support any items that don't fit C#'s unmanaged constraint - while the example you provided is a struct, it doesn't qualify as unmanaged because one of the fields is a C# array (AbilityTargetParam[]). Arrays in C# are managed types, and any struct that contains a managed type is also considered to be a managed type.
The good news is that there's a fairly simple fix to your error - replace your array with a NativeArray. The only downside is that you have to manage the memory yourself, so don't forget to dispose the array when you're done with it. See here for documentation: https://docs.unity3d.com/ScriptReference/Unity.Collections.NativeArray_1.html