mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkScene.SetLocalObject removed. Moved code into ClientScene.SetLocalObject and NetworkServer.SetLocalObject instead.
This commit is contained in:
parent
73bd9191d8
commit
7387b2a47a
@ -273,8 +273,24 @@ public static void DestroyAllClientObjects()
|
|||||||
|
|
||||||
public static void SetLocalObject(uint netId, NetworkIdentity ni)
|
public static void SetLocalObject(uint netId, NetworkIdentity ni)
|
||||||
{
|
{
|
||||||
// if still receiving initial state, dont set isClient
|
if (LogFilter.Debug) { Debug.Log("ClientScene.SetLocalObject " + netId + " " + ni); }
|
||||||
s_NetworkScene.SetLocalObject(netId, ni, s_IsSpawnFinished, false);
|
|
||||||
|
if (ni != null)
|
||||||
|
{
|
||||||
|
// if still receiving initial state, dont set isClient
|
||||||
|
if (s_IsSpawnFinished) ni.EnableIsClient();
|
||||||
|
|
||||||
|
// !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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NetworkIdentity.spawned[netId] = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject FindLocalObject(uint netId)
|
public static GameObject FindLocalObject(uint netId)
|
||||||
|
@ -18,28 +18,6 @@ internal void Shutdown()
|
|||||||
ClearSpawners();
|
ClearSpawners();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SetLocalObject(uint netId, NetworkIdentity ni, bool isClient, bool isServer)
|
|
||||||
{
|
|
||||||
if (LogFilter.Debug) { Debug.Log("SetLocalObject " + netId + " " + ni); }
|
|
||||||
|
|
||||||
if (ni != null)
|
|
||||||
{
|
|
||||||
if (isClient) ni.EnableIsClient();
|
|
||||||
if (isServer) ni.EnableIsServer();
|
|
||||||
|
|
||||||
// !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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NetworkIdentity.spawned[netId] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void RegisterPrefab(GameObject prefab, Guid newAssetId)
|
internal static void RegisterPrefab(GameObject prefab, Guid newAssetId)
|
||||||
{
|
{
|
||||||
NetworkIdentity view = prefab.GetComponent<NetworkIdentity>();
|
NetworkIdentity view = prefab.GetComponent<NetworkIdentity>();
|
||||||
|
@ -190,7 +190,21 @@ internal static void SetLocalObjectOnServer(uint netId, NetworkIdentity ni)
|
|||||||
{
|
{
|
||||||
if (LogFilter.Debug) { Debug.Log("SetLocalObjectOnServer " + netId + " " + ni); }
|
if (LogFilter.Debug) { Debug.Log("SetLocalObjectOnServer " + netId + " " + ni); }
|
||||||
|
|
||||||
s_NetworkScene.SetLocalObject(netId, ni, false, true);
|
if (ni != null)
|
||||||
|
{
|
||||||
|
ni.EnableIsServer();
|
||||||
|
|
||||||
|
// !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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NetworkIdentity.spawned[netId] = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void ActivateLocalClientScene()
|
internal static void ActivateLocalClientScene()
|
||||||
|
Loading…
Reference in New Issue
Block a user