diff --git a/Assets/Mirror/Runtime/ClientScene.cs b/Assets/Mirror/Runtime/ClientScene.cs
index 2d7ff5136..08d2c0e36 100644
--- a/Assets/Mirror/Runtime/ClientScene.cs
+++ b/Assets/Mirror/Runtime/ClientScene.cs
@@ -18,7 +18,7 @@ namespace Mirror
///
public static class ClientScene
{
- static bool isSpawnFinished;
+ internal static bool isSpawnFinished;
/// NetworkIdentity of the localPlayer
public static NetworkIdentity localPlayer { get; private set; }
@@ -30,7 +30,7 @@ public static class ClientScene
// This connection can be used to send messages to the server. There can
// only be one ClientScene and ready connection at a time.
// TODO ready ? NetworkClient.connection : null??????
- public static NetworkConnection readyConnection { get; private set; }
+ public static NetworkConnection readyConnection { get; internal set; }
[Obsolete("ClientScene.prefabs was moved to NetworkClient.prefabs")]
public static Dictionary prefabs => NetworkClient.prefabs;
@@ -435,16 +435,5 @@ public static void DestroyAllClientObjects()
Debug.LogError("Could not DestroyAllClientObjects because spawned list was modified during loop, make sure you are not modifying NetworkIdentity.spawned by calling NetworkServer.Destroy or NetworkServer.Spawn in OnDestroy or OnDisable.");
}
}
-
- // shutdown ////////////////////////////////////////////////////////////
- internal static void Shutdown()
- {
- ClearSpawners();
- spawnableObjects.Clear();
- readyConnection = null;
- ready = false;
- isSpawnFinished = false;
- DestroyAllClientObjects();
- }
}
}
diff --git a/Assets/Mirror/Runtime/NetworkClient.cs b/Assets/Mirror/Runtime/NetworkClient.cs
index 0530c3ea8..b9a344c1a 100644
--- a/Assets/Mirror/Runtime/NetworkClient.cs
+++ b/Assets/Mirror/Runtime/NetworkClient.cs
@@ -882,14 +882,20 @@ internal static void NetworkLateUpdate()
public static void Shutdown()
{
Debug.Log("Shutting down client.");
- ClientScene.Shutdown();
+ ClearSpawners();
+ ClientScene.spawnableObjects.Clear();
+ ClientScene.readyConnection = null;
+ ClientScene.ready = false;
+ ClientScene.isSpawnFinished = false;
+ ClientScene.DestroyAllClientObjects();
connectState = ConnectState.None;
handlers.Clear();
// disconnect the client connection.
// we do NOT call Transport.Shutdown, because someone only called
// NetworkClient.Shutdown. we can't assume that the server is
// supposed to be shut down too!
- Transport.activeTransport.ClientDisconnect();
+ if (Transport.activeTransport != null)
+ Transport.activeTransport.ClientDisconnect();
}
}
}
diff --git a/Assets/Mirror/Tests/Common/ClientSceneTestsBase.cs b/Assets/Mirror/Tests/Common/ClientSceneTestsBase.cs
index c882024a6..d7a0338ac 100644
--- a/Assets/Mirror/Tests/Common/ClientSceneTestsBase.cs
+++ b/Assets/Mirror/Tests/Common/ClientSceneTestsBase.cs
@@ -54,7 +54,7 @@ public void OneTimeSetUp()
[TearDown]
public virtual void TearDown()
{
- ClientScene.Shutdown();
+ NetworkClient.Shutdown();
// reset asset id in case they are changed by tests
validPrefabNetworkIdentity.assetId = validPrefabGuid;
diff --git a/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs b/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs
index 6cc5a84f6..d8d3be3b5 100644
--- a/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs
+++ b/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs
@@ -376,7 +376,6 @@ public void SendCommandInternal()
// clean up
RemoteCallHelper.RemoveDelegate(registeredHash);
// clear clientscene.readyconnection
- ClientScene.Shutdown();
NetworkClient.Shutdown();
NetworkServer.Shutdown();
Transport.activeTransport = null;
@@ -458,7 +457,6 @@ public void SendRPCInternal()
// clean up
RemoteCallHelper.RemoveDelegate(registeredHash);
// clear clientscene.readyconnection
- ClientScene.Shutdown();
NetworkServer.RemoveLocalConnection();
NetworkClient.Shutdown();
NetworkServer.Shutdown();
@@ -547,7 +545,6 @@ public void SendTargetRPCInternal()
// clean up
RemoteCallHelper.RemoveDelegate(registeredHash);
// clear clientscene.readyconnection
- ClientScene.Shutdown();
NetworkServer.RemoveLocalConnection();
NetworkClient.Shutdown();
NetworkServer.Shutdown();
diff --git a/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs b/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs
index 593205436..2b7a3e141 100644
--- a/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs
+++ b/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs
@@ -353,7 +353,6 @@ public void HostMode_IsFlags_Test()
// stop the client
NetworkClient.Shutdown();
NetworkServer.RemoveLocalConnection();
- ClientScene.Shutdown();
// stop the server
NetworkServer.Shutdown();