From 4fbbc0cbc1f20862b2d05e2958cf1ecd0f76c7d1 Mon Sep 17 00:00:00 2001 From: vis2k Date: Mon, 3 Oct 2022 08:49:06 +0200 Subject: [PATCH] NetworkManager: SetupClient() for consistency with SetupServer() --- Assets/Mirror/Core/NetworkManager.cs | 42 +++++++++++----------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/Assets/Mirror/Core/NetworkManager.cs b/Assets/Mirror/Core/NetworkManager.cs index 1a14a8d3b..2f16ad204 100644 --- a/Assets/Mirror/Core/NetworkManager.cs +++ b/Assets/Mirror/Core/NetworkManager.cs @@ -304,6 +304,20 @@ public void StartServer() } } + void SetupClient() + { + InitializeSingleton(); + + if (runInBackground) + Application.runInBackground = true; + + if (authenticator != null) + { + authenticator.OnStartClient(); + authenticator.OnClientAuthenticated.AddListener(OnClientAuthenticated); + } + } + /// Starts the client, connects it to the server with networkAddress. public void StartClient() { @@ -315,16 +329,7 @@ public void StartClient() mode = NetworkManagerMode.ClientOnly; - InitializeSingleton(); - - if (runInBackground) - Application.runInBackground = true; - - if (authenticator != null) - { - authenticator.OnStartClient(); - authenticator.OnClientAuthenticated.AddListener(OnClientAuthenticated); - } + SetupClient(); // In case this is a headless client... ConfigureHeadlessFrameRate(); @@ -354,16 +359,7 @@ public void StartClient(Uri uri) mode = NetworkManagerMode.ClientOnly; - InitializeSingleton(); - - if (runInBackground) - Application.runInBackground = true; - - if (authenticator != null) - { - authenticator.OnStartClient(); - authenticator.OnClientAuthenticated.AddListener(OnClientAuthenticated); - } + SetupClient(); RegisterClientMessages(); @@ -486,11 +482,7 @@ void StartHostClient() { //Debug.Log("NetworkManager ConnectLocalClient"); - if (authenticator != null) - { - authenticator.OnStartClient(); - authenticator.OnClientAuthenticated.AddListener(OnClientAuthenticated); - } + SetupClient(); networkAddress = "localhost"; NetworkServer.ActivateHostScene();