NetworkScene.SetLocalObject simplified

This commit is contained in:
vis2k 2018-12-16 17:21:32 +01:00
parent 64c120fe5e
commit a848c36d6e

View File

@ -22,18 +22,21 @@ internal void SetLocalObject(uint netId, NetworkIdentity ni, bool isClient, bool
{
if (LogFilter.Debug) { Debug.Log("SetLocalObject " + netId + " " + ni); }
if (ni == null)
if (ni != null)
{
NetworkIdentity.spawned[netId] = null;
return;
}
ni.UpdateClientServer(isClient, isServer);
// !Contains check needed to avoid dictionary 'out of sync' error
// because SetLocalObject is called from a foreach loop
if (!NetworkIdentity.spawned.ContainsKey(netId))
{
NetworkIdentity.spawned[netId] = ni;
}
ni.UpdateClientServer(isClient, isServer);
}
else
{
NetworkIdentity.spawned[netId] = null;
}
}
internal static void RegisterPrefab(GameObject prefab, Guid newAssetId)