Description
Our project has an array of NetworkVariables to simplify updating the representation of a grid / line of states.
After commit 8707582 NetworkVariable[]'s now have code generated for them where it seems to call NetworkVariable.Initialize on the array.
IL_0193: ldstr "BrokenNetworkBehaviour.AllInts cannot be null. All NetworkVariableBase instances must be initialized."
IL_0198: newobj instance void [netstandard]System.Exception::.ctor(string)
IL_019d: throw
IL_019e: nop
IL_019f: ldarg.0 // this
IL_01a0: ldfld class [Unity.Netcode.Runtime]Unity.Netcode.NetworkVariable`1<int32>[] BrokenNetworkBehaviour::AllInts
IL_01a5: ldarg.0 // this
IL_01a6: callvirt instance void [Unity.Netcode.Runtime]Unity.Netcode.NetworkVariableBase::Initialize(class [Unity.Netcode.Runtime]Unity.Netcode.NetworkBehaviour)
IL_01ab: nop
IL_01ac: ldarg.0 // this
IL_01ad: ldarg.0 // this
IL_01ae: ldfld class [Unity.Netcode.Runtime]Unity.Netcode.NetworkVariable`1<int32>[] BrokenNetworkBehaviour::AllInts
IL_01b3: ldstr "AllInts"
IL_01b8: call instance void [Unity.Netcode.Runtime]Unity.Netcode.NetworkBehaviour::__nameNetworkVariable(class [Unity.Netcode.Runtime]Unity.Netcode.NetworkVariableBase, string)
IL_01bd: nop
IL_01be: ldarg.0 // this
IL_01bf: ldfld class [netstandard]System.Collections.Generic.List`1<class [Unity.Netcode.Runtime]Unity.Netcode.NetworkVariableBase> [Unity.Netcode.Runtime]Unity.Netcode.NetworkBehaviour::NetworkVariableFields
IL_01c4: ldarg.0 // this
IL_01c5: ldfld class [Unity.Netcode.Runtime]Unity.Netcode.NetworkVariable`1<int32>[] BrokenNetworkBehaviour::AllInts
IL_01ca: callvirt instance void class [netstandard]System.Collections.Generic.List`1<class [Unity.Netcode.Runtime]Unity.Netcode.NetworkVariableBase>::Add(!0/*class [Unity.Netcode.Runtime]Unity.Netcode.NetworkVariableBase*/)
IL_01cf: nop
IL_01d0: ldarg.0 // this
IL_01d1: call instance void [Unity.Netcode.Runtime]Unity.Netcode.NetworkBehaviour::__initializeVariables()
Due to this an exception is thrown
ArrayTypeMismatchException: Attempted to access an element as a type incompatible with the array.
(wrapper stelemref) System.Object.virt_stelemref_class_small_idepth(intptr,object)
BrokenNetworkBehaviour.__initializeVariables () (at <71965e5b0ba541339b27dddeaa832202>:0)
Which ends up breaking the project, as the rest of the NetworkBehaviour initializeVariables code does not run.
Reproduce Steps
A simple repro project has been included.
ArrayOfNetworkVariables.zip
Environment
- OS: Win 10
- Unity Version: 2022.3.0f1 LTS
- Netcode Version: 1.4.0
- Netcode Commit: 1c74129
Description
Our project has an array of NetworkVariables to simplify updating the representation of a grid / line of states.
After commit 8707582 NetworkVariable[]'s now have code generated for them where it seems to call NetworkVariable.Initialize on the array.
Due to this an exception is thrown
Which ends up breaking the project, as the rest of the NetworkBehaviour initializeVariables code does not run.
Reproduce Steps
A simple repro project has been included.
ArrayOfNetworkVariables.zip
Environment