diff --git a/Assets/Scripts/Editor/NetworkConnectionHelperEditor.cs b/Assets/Scripts/Editor/NetworkConnectionHelperEditor.cs index 494aa8d..ca91eaf 100644 --- a/Assets/Scripts/Editor/NetworkConnectionHelperEditor.cs +++ b/Assets/Scripts/Editor/NetworkConnectionHelperEditor.cs @@ -54,6 +54,11 @@ namespace Northbound.Editor _helper.StartClient(); } + if (GUILayout.Button("Start Localhost Client", GUILayout.Height(30))) + { + _helper.StartLocalhostClient(); + } + EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(!IsConnected()); diff --git a/Assets/Scripts/NetworkConnectionHelper.cs b/Assets/Scripts/NetworkConnectionHelper.cs index 10e1423..856dc7d 100644 --- a/Assets/Scripts/NetworkConnectionHelper.cs +++ b/Assets/Scripts/NetworkConnectionHelper.cs @@ -62,6 +62,23 @@ namespace Northbound } } + public void StartLocalhostClient() + { + if (NetworkManager.Singleton == null) + { + Debug.LogError("[NetworkConnectionHelper] NetworkManager not found!"); + return; + } + + ConfigureTransport("127.0.0.1", port); + + if (!NetworkManager.Singleton.IsClient && !NetworkManager.Singleton.IsServer) + { + NetworkManager.Singleton.StartClient(); + Debug.Log($"[NetworkConnectionHelper] Connecting to localhost:{port}"); + } + } + public void StartServer() { if (NetworkManager.Singleton == null)