File tree 1 file changed +29
-3
lines changed
com.unity.netcode.gameobjects/Runtime/Spawning
1 file changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -1581,20 +1581,46 @@ internal void HandleNetworkObjectShow()
1581
1581
{
1582
1582
foreach ( var entry in ClientsToShowObject )
1583
1583
{
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
+ }
1585
1598
}
1586
1599
ClientsToShowObject . Clear ( ) ;
1587
1600
ObjectsToShowToClient . Clear ( ) ;
1588
1601
return ;
1589
1602
}
1590
1603
1591
- // Handle NetworkObjects to show
1604
+ // Server or Host handling of NetworkObjects to show
1592
1605
foreach ( var client in ObjectsToShowToClient )
1593
1606
{
1594
1607
ulong clientId = client . Key ;
1595
1608
foreach ( var networkObject in client . Value )
1596
1609
{
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
+ }
1598
1624
}
1599
1625
}
1600
1626
ObjectsToShowToClient . Clear ( ) ;
You can’t perform that action at this time.
0 commit comments