개발자용 멀티플레이 기능 추가
This commit is contained in:
93
Assets/Scripts/Editor/QuickNetworkSetupEditor.cs
Normal file
93
Assets/Scripts/Editor/QuickNetworkSetupEditor.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Northbound.Editor
|
||||
{
|
||||
public class QuickNetworkSetupEditor
|
||||
{
|
||||
[MenuItem("Tools/Network/Quick Setup for IP Connection")]
|
||||
public static void QuickSetup()
|
||||
{
|
||||
bool disableAutoHost = EditorUtility.DisplayDialog(
|
||||
"Quick Network Setup",
|
||||
"This will set up your scene for manual IP-based network connections.\n\n" +
|
||||
"It will:\n" +
|
||||
"- Create a NetworkConnectionHelper component\n" +
|
||||
"- Disable AutoHost (to prevent auto-start)\n\n" +
|
||||
"Do you want to disable AutoHost?",
|
||||
"Yes, disable AutoHost",
|
||||
"No, keep AutoHost"
|
||||
);
|
||||
|
||||
CreateNetworkHelper();
|
||||
|
||||
if (disableAutoHost)
|
||||
{
|
||||
DisableAutoHost();
|
||||
}
|
||||
|
||||
EditorUtility.DisplayDialog(
|
||||
"Setup Complete",
|
||||
"Quick network setup complete!\n\n" +
|
||||
"Next steps:\n" +
|
||||
"1. Open Window > Network > Connection Manager\n" +
|
||||
"2. Or use the NetworkConnectionHelper in Inspector\n" +
|
||||
"3. Start Host on one instance\n" +
|
||||
"4. Start Client on other instances with the Host's IP",
|
||||
"OK"
|
||||
);
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Network/Create Connection Helper")]
|
||||
public static void CreateNetworkHelper()
|
||||
{
|
||||
if (Object.FindObjectOfType<NetworkConnectionHelper>() == null)
|
||||
{
|
||||
GameObject helperObj = new GameObject("NetworkConnectionHelper");
|
||||
helperObj.AddComponent<NetworkConnectionHelper>();
|
||||
Selection.activeGameObject = helperObj;
|
||||
Debug.Log("[QuickNetworkSetup] NetworkConnectionHelper created");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("[QuickNetworkSetup] NetworkConnectionHelper already exists");
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Network/Disable AutoHost")]
|
||||
public static void DisableAutoHost()
|
||||
{
|
||||
AutoHost[] autoHosts = Object.FindObjectsByType<AutoHost>(FindObjectsSortMode.None);
|
||||
if (autoHosts.Length > 0)
|
||||
{
|
||||
foreach (var autoHost in autoHosts)
|
||||
{
|
||||
autoHost.enabled = false;
|
||||
}
|
||||
Debug.Log($"[QuickNetworkSetup] Disabled {autoHosts.Length} AutoHost component(s)");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("[QuickNetworkSetup] No AutoHost components found");
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Network/Enable AutoHost")]
|
||||
public static void EnableAutoHost()
|
||||
{
|
||||
AutoHost[] autoHosts = Object.FindObjectsByType<AutoHost>(FindObjectsSortMode.None);
|
||||
if (autoHosts.Length > 0)
|
||||
{
|
||||
foreach (var autoHost in autoHosts)
|
||||
{
|
||||
autoHost.enabled = true;
|
||||
}
|
||||
Debug.Log($"[QuickNetworkSetup] Enabled {autoHosts.Length} AutoHost component(s)");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("[QuickNetworkSetup] No AutoHost components found");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user