Files
Northbound/Assets/Scripts/ShortcutNetworkStarter.cs
dal4segno 10b496dfae 네트워크 멀티플레이 환경 문제 수정
관련 문제가 다시 발생하면 이 커밋으로 돌아올 것
2026-02-02 04:24:14 +09:00

51 lines
1.4 KiB
C#

using UnityEngine;
using UnityEngine.InputSystem;
using Unity.Netcode;
namespace Northbound
{
public class ShortcutNetworkStarter : MonoBehaviour
{
[Header("Input Actions")]
[SerializeField] private InputActionReference startAsClientAction;
private bool _isClientStarted = false;
private void Start()
{
if (startAsClientAction != null && startAsClientAction.action != null)
{
startAsClientAction.action.performed += StartAsClient;
}
}
private void OnDestroy()
{
if (startAsClientAction != null && startAsClientAction.action != null)
{
startAsClientAction.action.performed -= StartAsClient;
}
}
private void StartAsClient(InputAction.CallbackContext context)
{
if (NetworkManager.Singleton == null)
{
Debug.LogError("[ShortcutNetworkStarter] NetworkManager.Singleton이 null입니다!");
return;
}
if (NetworkManager.Singleton.IsClient)
{
Debug.Log("[ShortcutNetworkStarter] 이미 클라이언트 모드입니다.");
return;
}
_isClientStarted = true;
Debug.Log("[ShortcutNetworkStarter] 클라이언트 모드로 시작합니다...");
NetworkManager.Singleton.StartClient();
}
}
}