블록 조준 시스템 제작
및 기본 에디터 자동 호스트화
This commit is contained in:
26
Assets/Scripts/GameBase/AutoHost.cs
Normal file
26
Assets/Scripts/GameBase/AutoHost.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/GameBase/AutoHost.cs.meta
Normal file
2
Assets/Scripts/GameBase/AutoHost.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 158afddc7f1d50a42831c73d5e8dc87b
|
||||
Reference in New Issue
Block a user