mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
NetworkScene.SetLocalObject simplified
This commit is contained in:
parent
64c120fe5e
commit
a848c36d6e
@ -22,18 +22,21 @@ internal void SetLocalObject(uint netId, NetworkIdentity ni, bool isClient, bool
|
|||||||
{
|
{
|
||||||
if (LogFilter.Debug) { Debug.Log("SetLocalObject " + netId + " " + ni); }
|
if (LogFilter.Debug) { Debug.Log("SetLocalObject " + netId + " " + ni); }
|
||||||
|
|
||||||
if (ni == null)
|
if (ni != null)
|
||||||
{
|
{
|
||||||
NetworkIdentity.spawned[netId] = null;
|
ni.UpdateClientServer(isClient, isServer);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// !Contains check needed to avoid dictionary 'out of sync' error
|
||||||
|
// because SetLocalObject is called from a foreach loop
|
||||||
if (!NetworkIdentity.spawned.ContainsKey(netId))
|
if (!NetworkIdentity.spawned.ContainsKey(netId))
|
||||||
{
|
{
|
||||||
NetworkIdentity.spawned[netId] = ni;
|
NetworkIdentity.spawned[netId] = ni;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ni.UpdateClientServer(isClient, isServer);
|
else
|
||||||
|
{
|
||||||
|
NetworkIdentity.spawned[netId] = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void RegisterPrefab(GameObject prefab, Guid newAssetId)
|
internal static void RegisterPrefab(GameObject prefab, Guid newAssetId)
|
||||||
|
Loading…
Reference in New Issue
Block a user