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(); } } }