네트워크 멀티플레이 대응

This commit is contained in:
2026-01-31 20:49:23 +09:00
parent 1152093521
commit c5bcf265d0
69 changed files with 2766 additions and 1392 deletions

View File

@@ -0,0 +1,52 @@
using UnityEngine;
using Unity.Netcode;
public class SmartAutoHost : MonoBehaviour
{
#if UNITY_EDITOR
private void Start()
{
if (NetworkManager.Singleton == null)
{
Debug.LogError("[SmartAutoHost] NetworkManager not found!");
return;
}
if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsClient)
{
return;
}
bool isMainEditor = IsMainEditor();
if (isMainEditor)
{
NetworkManager.Singleton.StartHost();
Debug.Log("<color=yellow><b>[SmartAutoHost]</b> MAIN EDITOR → Starting as HOST</color>");
}
else
{
NetworkManager.Singleton.StartClient();
Debug.Log("<color=blue><b>[SmartAutoHost]</b> SECONDARY EDITOR → Connecting as CLIENT</color>");
}
}
private bool IsMainEditor()
{
string[] args = System.Environment.GetCommandLineArgs();
return System.Array.Exists(args, arg => arg == "-mainEditor");
}
#else
private void Start()
{
// 빌드된 버전은 항상 클라이언트
if (NetworkManager.Singleton != null &&
!NetworkManager.Singleton.IsServer &&
!NetworkManager.Singleton.IsClient)
{
NetworkManager.Singleton.StartClient();
Debug.Log("<color=blue>[SmartAutoHost] Build → Connecting as CLIENT</color>");
}
}
#endif
}