Unity-Technologies / com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.15k stars 435 forks source link

Best way to represent strings in NetworkVariables in pre8+ #1919

Closed ezoray closed 1 year ago

ezoray commented 2 years ago

As mentioned in this thread FixedString*Bytes types can no longer be used directly as network variables. I see in the pre8 release notes the handling of structs has changed, it mentions RPC's but it seems to relate to network variables as well.

With that in mind, what's the best way to have network variables containing string types, something like this?

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

Stealcase commented 2 years ago

For those coming here through the google/the Unity Forums thread, check out https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/pull/1901 for details on why this changed.

Also Documented here: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/releases/tag/1.0.0-pre.8

will-mearns commented 2 years ago

@ashwinimurt , can you see if this is in our backlog?

qkdreyer commented 2 years ago

https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/pull/1961

ShadauxCat commented 1 year ago

Closing this very old issue - we added fixed string support back to NetworkVariables in 1.0.0-pre.10, as @qkdreyer pointed out, in #1961