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.16k stars 435 forks source link

GlobalObjectIdHash contains invalid if networked prefab was edited from Prefab mode #3151

Open FylmTM opened 13 hours ago

FylmTM commented 13 hours ago

Description

Whenever I edit Networked Prefab in Prefab mode (double click on prefab in project tool window), then attempting to establish connection between server & client fails with:

[Netcode] NetworkConfig mismatch. The configuration between the server and client does not match
UnityEngine.Debug:LogWarning (object)
Unity.Netcode.NetworkLog:LogWarning (string) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Logging/NetworkLog.cs:28)
Unity.Netcode.ConnectionRequestMessage:Deserialize (Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkContext&,int) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Messaging/Messages/ConnectionRequestMessage.cs:169)
...

If I edit Networked Prefab outside of Prefab mode (single click on prefab in project tool window), then everything works as expected. This also server as a workaround. Toggling any property on a prefab in this mode "fixes" error.

In general if you check GlobalObjectIdHash property for prefab, then it's different between these 2 views.

My observations:

Reproduce Steps

I have written down detailed reproduction steps in Unity forum post: https://discussions.unity.com/t/multiplayer-play-mode-error-when-connecting-from-to-virtual-player-after-editing-networked-prefab/1564025

Short version:

  1. Open Networked Prefab in prefab edit mode (double click on prefab)
  2. Edit any property (e.g. sprite color)
  3. Attempt to connect from client to server (using default Network Manager buttons)

Actual Outcome

Error:

[Netcode] NetworkConfig mismatch. The configuration between the server and client does not match

Expected Outcome

Connection established successfully.

Screenshots

Player prefab inspector in "regular mode". GlobalObjectIdHash: 3475022634 Image

Player prefab inspector in "prefab mode". GlobalObjectIdHash: 3871928766 Image

Environment

Additional Context

-

FylmTM commented 13 hours ago

Related: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2653