2026-06-11 기본 매니저 구성

This commit is contained in:
skrwns304@gmail.com
2026-06-11 01:06:48 +09:00
parent 37669d9592
commit 8e3cc91d92
20 changed files with 608 additions and 4 deletions

View File

@@ -0,0 +1,42 @@
using System;
using UnityEngine;
using UnityEngine.InputSystem;
public class InputManager : MonoBehaviour, GameInput.IPlayerActions
{
// 외부에서 InputManager.Instance.OnXxx_Event += handler 형태로 구독.
public static InputManager Instance { get; private set; }
private GameInput _input;
// ─── 입력 이벤트들 (PlayerController 등이 구독) ──────────────────────
public event Action OnJump_Event; // 한 번씩 (눌렀을 때)
private void Awake()
{
if (Instance == null)
{
Instance = this; //만들어진 자신을 인스턴스로 설정
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject); //이미 인스턴스가 있으면 자신을 파괴
}
_input = new GameInput();
// IPlayerActions의 OnJump/... 메서드를 인풋 액션의 콜백으로 자동 연결.
_input.Player.SetCallbacks(this);
}
// GameInput은 활성/비활성 토글이 필요한 자원 ?. 처리로 Awake보다 OnEnable이 먼저 호출되는 경우 보호.
private void OnEnable() => _input?.Player.Enable();
private void OnDisable() => _input?.Player.Disable();
private void OnDestroy() => _input?.Dispose();
public void OnJump(InputAction.CallbackContext ctx)
{
if (ctx.phase == InputActionPhase.Started)
OnJump_Event?.Invoke();
}
}