FixedString32Bytes not serializable after NetworkString implementation

We are working with Unity Netcode for Gameobjects version 1.0.0-pre.9 and despite having implemented the INetworkSerializable for FixedString32Bytes, we are still experiencing this error.


Exception: Type Unity.Collections.FixedString32Bytes is not serializable - it must implement either INetworkSerializable or ISerializeByMemcpy
Unity.Netcode.NetworkVariableSerialization`1[T].WriteValue[TForMethod] (Unity.Netcode.FastBufferWriter writer, TForMethod& value) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.9/Runtime/NetworkVariable/NetworkVariableSerialization.cs:92)
Unity.Netcode.NetworkVariableSerialization`1[T].Write (Unity.Netcode.FastBufferWriter writer, T& value) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.9/Runtime/NetworkVariable/NetworkVariableSerialization.cs:144)
Unity.Netcode.NetworkVariable`1[T].WriteField (Unity.Netcode.FastBufferWriter writer) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.9/Runtime/NetworkVariable/NetworkVariable.cs:124)
Unity.Netcode.NetworkVariable`1[T].WriteDelta (Unity.Netcode.FastBufferWriter writer) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.9/Runtime/NetworkVariable/NetworkVariable.cs:89)
Unity.Netcode.NetworkVariableDeltaMessage.Serialize (Unity.Netcode.FastBufferWriter writer) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.9/Runtime/Messaging/Messages/NetworkVariableDeltaMessage.cs:94)
Unity.Netcode.NetworkBehaviour.NetworkVariableUpdate (System.UInt64 targetClientId, System.Int32 behaviourIndex) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.9/Runtime/Core/NetworkBehaviour.cs:640)
Unity.Netcode.NetworkBehaviour.VariableUpdate (System.UInt64 targetClientId) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.9/Runtime/Core/NetworkBehaviour.cs:594)
Unity.Netcode.NetworkBehaviourUpdater.NetworkBehaviourUpdate (Unity.Netcode.NetworkManager networkManager) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.9/Runtime/Core/NetworkBehaviourUpdater.cs:36)
Unity.Netcode.NetworkManager.OnNetworkManagerTick () (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.9/Runtime/Core/NetworkManager.cs:1411)
Unity.Netcode.NetworkTickSystem.UpdateTick (System.Double localTimeSec, System.Double serverTimeSec) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.9/Runtime/Timing/NetworkTickSystem.cs:96)
Unity.Netcode.NetworkManager.OnNetworkPreUpdate () (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.9/Runtime/Core/NetworkManager.cs:1375)
Unity.Netcode.NetworkManager.NetworkUpdate (Unity.Netcode.NetworkUpdateStage updateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.9/Runtime/Core/NetworkManager.cs:1322)
Unity.Netcode.NetworkUpdateLoop.RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage updateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.9/Runtime/Core/NetworkUpdateLoop.cs:149)
Unity.Netcode.NetworkUpdateLoop+NetworkPreUpdate+<>c.<CreateLoopSystem>b__0_0 () (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.9/Runtime/Core/NetworkUpdateLoop.cs:196)

This is how we implemented it. Are we doing something wrong or is the problem somewhere else? (We also tried INetworkSerializeByMemcpy, the result is the same)

public struct NetworkString : INetworkSerializable
{
    private ForceNetworkSerializeByMemcpy<FixedString32Bytes> data;

    public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
    {
        serializer.SerializeValue(ref data);
    }

    public override string ToString() => data.Value.ToString();

    public static implicit operator string(NetworkString networkString) => networkString.ToString();
    public static implicit operator NetworkString(string s) => new NetworkString { data = new FixedString32Bytes(s) };
}

We took the code from this tutorial (Time is 16:38):

Anybody has any idea how we can solve this?

Thanks for your attention!

Ok, we finally figured out the problem. Apparently, somewhere in code that was not made from us, someone was still using NetworkVariable, so the error is rightfully showing up. The struggle for us was the fact that in no part of the error it was mentioned where the offensive code was (since we are dealing with a generic class), so it took us some time to find it. If you are downloading code or examples from sources that worked with versions prior to pre.7, you should take care for any instance of NetworkVariable.