26 lines
805 B
C#
26 lines
805 B
C#
using UnityEngine;
|
|
using Unity.Netcode;
|
|
|
|
public class AutoHost : MonoBehaviour
|
|
{
|
|
// 에디터에서만 작동하도록 설정
|
|
void Start()
|
|
{
|
|
#if UNITY_EDITOR
|
|
// 1. NetworkManager가 씬에 존재하는지 확인
|
|
if (NetworkManager.Singleton != null)
|
|
{
|
|
// 2. 이미 서버나 클라이언트가 실행 중이 아닐 때만 실행
|
|
if (!NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsClient)
|
|
{
|
|
NetworkManager.Singleton.StartHost();
|
|
Debug.Log("<color=yellow><b>[AutoHost]</b> 에디터 전용 호스트 자동 시작됨</color>");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("[AutoHost] NetworkManager를 찾을 수 없습니다!");
|
|
}
|
|
#endif
|
|
}
|
|
} |