From 11dc4a9f6064694e1d5236c274fff4de44850d50 Mon Sep 17 00:00:00 2001 From: MrGadget1024 <9826063+MrGadget1024@users.noreply.github.com> Date: Fri, 24 Nov 2023 18:03:05 -0500 Subject: [PATCH] fix(NetworkManager): Move networkAddress check up in StartClient - If we're going to abort for this, do it before setting anything up. - If/when the networkAddress is later set, we won't have issue with double initilization when StartClient is called again. --- Assets/Mirror/Core/NetworkManager.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Assets/Mirror/Core/NetworkManager.cs b/Assets/Mirror/Core/NetworkManager.cs index 22ae8cff1..746985dbe 100644 --- a/Assets/Mirror/Core/NetworkManager.cs +++ b/Assets/Mirror/Core/NetworkManager.cs @@ -404,6 +404,12 @@ public void StartClient() return; } + if (string.IsNullOrWhiteSpace(networkAddress)) + { + Debug.LogError("Must set the Network Address field in the manager"); + return; + } + mode = NetworkManagerMode.ClientOnly; SetupClient(); @@ -413,13 +419,6 @@ public void StartClient() RegisterClientMessages(); - if (string.IsNullOrWhiteSpace(networkAddress)) - { - Debug.LogError("Must set the Network Address field in the manager"); - return; - } - // Debug.Log($"NetworkManager StartClient address:{networkAddress}"); - NetworkClient.Connect(networkAddress); OnStartClient();