- Home /
Question by
Louiebloo · Mar 01 at 02:36 AM ·
networkingserializationmultiplayer-networking
How to NetworkSerialize an Array? Always getting non-nullable Error
I cant create nested custom structs to serialize in NetworkVariables without getting a "the type xx must be a non-nullable value type". Here is a very simple example with a Parent struct and Child struct both inheriting INetworkSerializable. The line NetworkVariable<Parent> test = new NetworkVariable<Parent>();
throws the error.
public struct Child : INetworkSerializable
{
public int turnsActive;
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
throw new System.NotImplementedException();
}
}
public struct Parent : INetworkSerializable
{
public int whatever;
public Child[] allAffects;
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
throw new System.NotImplementedException();
}
}
NetworkVariable<Parent> test = new NetworkVariable<Parent>();
I see another thread with the seemingly the same issue:
Is this going to be fixed? Its currently extremly difficult to use the multiplayer framework without being able to sync very basic data.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613053630im_/https://answers.unity.com/themes/thub/images/avi.jpg)