I need help with String Network Variables

I want to create a String network variable. I read online i could use FixedString64Bytes but when i try

private NetworkVariable<FixedString64Bytes> playerName = new NetworkVariable<FixedString64Bytes>();

i get following error message:
Type Unity.Collections.FixedString64Bytes is not serializable - it must implement either INetworkSerializable or ISerializeByMemcpy

I also tried creating a custom struct, but i get an error in the SerializeValue line(the constraints for type arguments are not satisfied), which is weird because i copied this code from a youtube tutorial)

public struct NetworkString : INetworkSerializable
{
    private FixedString32Bytes info;
    public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
    {
        serializer.SerializeValue(ref info);
    }

What is the best way to send strings through network variables?
thank you in advance

I think you’ll find the answer in this very recent thread: NetworkString script gives an error CS0315

thank you very much :slight_smile:

Or you could try the much simpler solution:

    [SerializeField]
    public NetworkVariable<ForceNetworkSerializeByMemcpy<FixedString64Bytes>> stringVar = new NetworkVariable<ForceNetworkSerializeByMemcpy<FixedString64Bytes>>();

That is so ugly @ClearDark :hushed: But if it works I’ll give it a try :stuck_out_tongue: