Skip to content

Commit 8ec8e95

Browse files
fix
up-port of #3029
1 parent 1b900a4 commit 8ec8e95

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs

+29-3
Original file line numberDiff line numberDiff line change
@@ -1581,20 +1581,46 @@ internal void HandleNetworkObjectShow()
15811581
{
15821582
foreach (var entry in ClientsToShowObject)
15831583
{
1584-
SendSpawnCallForObserverUpdate(entry.Value.ToArray(), entry.Key);
1584+
if (entry.Key != null && entry.Key.IsSpawned)
1585+
{
1586+
try
1587+
{
1588+
SendSpawnCallForObserverUpdate(entry.Value.ToArray(), entry.Key);
1589+
}
1590+
catch (Exception ex)
1591+
{
1592+
if (NetworkManager.LogLevel <= LogLevel.Developer)
1593+
{
1594+
Debug.LogException(ex);
1595+
}
1596+
}
1597+
}
15851598
}
15861599
ClientsToShowObject.Clear();
15871600
ObjectsToShowToClient.Clear();
15881601
return;
15891602
}
15901603

1591-
// Handle NetworkObjects to show
1604+
// Server or Host handling of NetworkObjects to show
15921605
foreach (var client in ObjectsToShowToClient)
15931606
{
15941607
ulong clientId = client.Key;
15951608
foreach (var networkObject in client.Value)
15961609
{
1597-
SendSpawnCallForObject(clientId, networkObject);
1610+
if (networkObject != null && networkObject.IsSpawned)
1611+
{
1612+
try
1613+
{
1614+
SendSpawnCallForObject(clientId, networkObject);
1615+
}
1616+
catch (Exception ex)
1617+
{
1618+
if (NetworkManager.LogLevel <= LogLevel.Developer)
1619+
{
1620+
Debug.LogException(ex);
1621+
}
1622+
}
1623+
}
15981624
}
15991625
}
16001626
ObjectsToShowToClient.Clear();

0 commit comments

Comments
 (0)