Skip to content

Commit

Permalink
fix: Server only session issues with parent synchronize and networkob…
Browse files Browse the repository at this point in the history
…jecteditor (#3139)

* fix

Fixed issue where NetworkObjectEditor would throw an exception when you tried to view the NetworkObject.Observers in the inspector view when in playmode.

* fix

Fixed issue where the parent sync message was ignoring deserialization on the server side (clients can parent if the NetworkObject has the allow clients to parent flag set).
  • Loading branch information
NoelStephensUnity authored Nov 24, 2024
1 parent 86ddd7d commit 2b0a9b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 8 additions & 0 deletions com.unity.netcode.gameobjects/Editor/NetworkObjectEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ public override void OnInspectorGUI()

while (observerClientIds.MoveNext())
{
if (!m_NetworkObject.NetworkManager.ConnectedClients.ContainsKey(observerClientIds.Current))
{
if ((observerClientIds.Current == 0 && m_NetworkObject.NetworkManager.IsHost) || observerClientIds.Current > 0)
{
Debug.LogWarning($"Client-{observerClientIds.Current} is listed as an observer but is not connected!");
}
continue;
}
if (m_NetworkObject.NetworkManager.ConnectedClients[observerClientIds.Current].PlayerObject != null)
{
EditorGUILayout.ObjectField($"ClientId: {observerClientIds.Current}", m_NetworkObject.NetworkManager.ConnectedClients[observerClientIds.Current].PlayerObject, typeof(GameObject), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ public void Serialize(FastBufferWriter writer, int targetVersion)
public bool Deserialize(FastBufferReader reader, ref NetworkContext context, int receivedMessageVersion)
{
var networkManager = (NetworkManager)context.SystemOwner;
if (!networkManager.IsClient)
{
return false;
}

ByteUnpacker.ReadValueBitPacked(reader, out NetworkObjectId);
reader.ReadValueSafe(out m_BitField);
Expand Down

0 comments on commit 2b0a9b2

Please sign in to comment.