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.
This commit is contained in:
MrGadget1024 2023-11-24 18:03:05 -05:00
parent dfec9a713e
commit 11dc4a9f60

View File

@ -404,6 +404,12 @@ public void StartClient()
return; return;
} }
if (string.IsNullOrWhiteSpace(networkAddress))
{
Debug.LogError("Must set the Network Address field in the manager");
return;
}
mode = NetworkManagerMode.ClientOnly; mode = NetworkManagerMode.ClientOnly;
SetupClient(); SetupClient();
@ -413,13 +419,6 @@ public void StartClient()
RegisterClientMessages(); 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); NetworkClient.Connect(networkAddress);
OnStartClient(); OnStartClient();