개발자용 멀티플레이 기능 추가

This commit is contained in:
2026-02-02 20:26:28 +09:00
parent b4c22edcbd
commit 9dea9daaa9
23 changed files with 1754 additions and 13 deletions

View File

@@ -3,24 +3,38 @@ using Unity.Netcode;
public class AutoHost : MonoBehaviour
{
// 에디터에서만 작동하도록 설정
void Start()
[Header("Auto Host Settings")]
[SerializeField] private bool enableAutoHost = true;
[SerializeField] private bool onlyInEditor = true;
private void Start()
{
#if UNITY_EDITOR
// 1. NetworkManager가 씬에 존재하는지 확인
if (NetworkManager.Singleton != null)
if (ShouldAutoStart())
{
// 2. 이미 서버나 클라이언트가 실행 중이 아닐 때만 실행
if (!NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsClient)
if (NetworkManager.Singleton != null)
{
NetworkManager.Singleton.StartHost();
Debug.Log("<color=yellow><b>[AutoHost]</b> 에디터 전용 호스트 자동 시작됨</color>");
if (!NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsClient)
{
NetworkManager.Singleton.StartHost();
Debug.Log("<color=yellow><b>[AutoHost]</b> Auto-host started</color>");
}
}
else
{
Debug.LogError("[AutoHost] NetworkManager not found!");
}
}
else
{
Debug.LogError("[AutoHost] NetworkManager를 찾을 수 없습니다!");
}
}
private bool ShouldAutoStart()
{
if (!enableAutoHost)
return false;
#if UNITY_EDITOR
return true;
#else
return !onlyInEditor;
#endif
}
}