SpawnObserversForConnection: warning instead of NullReferenceException in case of null entries

This commit is contained in:
vis2k 2023-01-06 13:57:08 +01:00
parent e395f29999
commit 50b9517c0f

View File

@ -1051,6 +1051,15 @@ static void SpawnObserversForConnection(NetworkConnectionToClient conn)
// internally sends a spawn message for each one to the connection.
foreach (NetworkIdentity identity in spawned.Values)
{
// show a warning in case of unexpected null entries.
// keep spawning the other entries though.
// https://github.com/MirrorNetworking/Mirror/issues/3330
if (identity == null)
{
Debug.LogWarning("SpawnObserversForConnection: skipping null entry in spawned. This should not happen.");
continue;
}
// try with far away ones in ummorpg!
if (identity.gameObject.activeSelf) //TODO this is different
{