2026-03-28 인벤토리 90%
This commit is contained in:
@@ -31,8 +31,9 @@ public class InputManager : MonoBehaviour
|
||||
public event Action OnKeyDown_UpArrowEvent;
|
||||
public event Action OnKeyDown_DownArrowEvent;
|
||||
public event Action OnKeyDown_EnterEvent;
|
||||
|
||||
public event Action OnKeyDown_IKeyEvent;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
@@ -76,13 +77,13 @@ public void SetUIInputMap(string mapName)
|
||||
_uiInputActionMap = _playerInput?.actions?.FindActionMap(mapName);
|
||||
if (_uiInputActionMap == null) return;
|
||||
|
||||
// 맵 활성화
|
||||
_uiInputActionMap.Enable();
|
||||
|
||||
//바인딩
|
||||
BindActionUI("OnKeyDown_UpArrow", OnKeyDown_UpArrow);
|
||||
BindActionUI("OnKeyDown_DownArrow", OnKeyDown_DownArrow);
|
||||
BindActionUI("OnKeyDown_Enter", OnKeyDown_Enter);
|
||||
BindActionUI("OnkeyDown_IKey", OnKeyDown_IKey);
|
||||
|
||||
_uiInputActionMap.Disable();
|
||||
|
||||
}
|
||||
|
||||
@@ -91,9 +92,6 @@ public void SetCharacterInputMap(string mapName)
|
||||
_characterInputActionMap = _playerInput?.actions?.FindActionMap(mapName);
|
||||
if (_characterInputActionMap == null) return;
|
||||
|
||||
// 맵 활성화
|
||||
_characterInputActionMap.Enable();
|
||||
|
||||
//바인딩
|
||||
BindActionCharacter("Scroll", OnMouseScroll);
|
||||
BindActionCharacter("Move", OnMove);
|
||||
@@ -104,6 +102,9 @@ public void SetCharacterInputMap(string mapName)
|
||||
BindActionCharacter("Dodge", OnDodge);
|
||||
BindActionCharacter("NormalAttack", OnNormalAttack);
|
||||
BindActionCharacter("HeavyAttack", OnHeavyAttack);
|
||||
BindActionCharacter("OnkeyDown_IKey", OnKeyDown_IKey);
|
||||
|
||||
_characterInputActionMap.Disable();
|
||||
|
||||
}
|
||||
|
||||
@@ -120,8 +121,6 @@ private void BindActionUI(string actionName, Action<InputAction.CallbackContext>
|
||||
action.performed += callback;
|
||||
action.canceled += callback;
|
||||
action.started += callback;
|
||||
|
||||
action.Enable();
|
||||
}
|
||||
}
|
||||
private void BindActionCharacter(string actionName, Action<InputAction.CallbackContext> callback)
|
||||
@@ -136,11 +135,14 @@ private void BindActionCharacter(string actionName, Action<InputAction.CallbackC
|
||||
action.performed += callback;
|
||||
action.canceled += callback;
|
||||
action.started += callback;
|
||||
|
||||
action.Enable();
|
||||
}
|
||||
}
|
||||
|
||||
public void ActiveOnlyOneActionMap(string actionMapName)
|
||||
{
|
||||
_playerInput.SwitchCurrentActionMap(actionMapName);
|
||||
}
|
||||
|
||||
#region 캐릭터 조작
|
||||
private void OnMouseScroll(InputAction.CallbackContext ctx)
|
||||
{
|
||||
@@ -229,5 +231,11 @@ private void OnKeyDown_Enter(InputAction.CallbackContext ctx)
|
||||
if (ctx.started)
|
||||
OnKeyDown_EnterEvent?.Invoke();
|
||||
}
|
||||
|
||||
private void OnKeyDown_IKey(InputAction.CallbackContext ctx)
|
||||
{
|
||||
if(ctx.started)
|
||||
OnKeyDown_IKeyEvent?.Invoke();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
public class InventoryManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject _inventoryRoot;
|
||||
[SerializeField] private GameObject _inventoryContentRoot;
|
||||
[SerializeField] private GameObject _slotPrefab;
|
||||
|
||||
@@ -51,21 +50,6 @@ private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
public void InventoryToggle()
|
||||
{
|
||||
if (_inventoryRoot != null)
|
||||
{
|
||||
InventoryOnOff(!_inventoryRoot.activeSelf);
|
||||
}
|
||||
}
|
||||
|
||||
public void InventoryOnOff(bool onOff)
|
||||
{
|
||||
if (_inventoryRoot != null)
|
||||
{
|
||||
_inventoryRoot.SetActive(onOff);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateUI()
|
||||
{
|
||||
|
||||
@@ -95,6 +95,9 @@ public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
InputManager.Instance.SetUIInputMap("InGameUI");
|
||||
InputManager.Instance.SetCharacterInputMap("Character");
|
||||
|
||||
//일단 하나의 액션맵만 사용
|
||||
InputManager.Instance.ActiveOnlyOneActionMap("Character");
|
||||
|
||||
//카메라 줌 매핑
|
||||
InputManager.Instance.OnMouseScrollEvent += GameManager.Instance.Camera.ZoomCamera;
|
||||
|
||||
@@ -108,6 +111,9 @@ public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
//InputManager.Instance.OnNormalAttackEvent;
|
||||
//InputManager.Instance.OnHeavyAttackEvent;
|
||||
|
||||
//UI매핑
|
||||
InputManager.Instance.OnKeyDown_IKeyEvent += GameManager.Instance.InGameUI.InventoryToggle;
|
||||
|
||||
//화면 켜기
|
||||
}
|
||||
|
||||
@@ -141,9 +147,17 @@ private void OnDestroy()
|
||||
InputManager.Instance.OnMoveEvent -= CurrentCharacterController.MoveInput;
|
||||
InputManager.Instance.OnSprintEvent -= CurrentCharacterController.SprintInput;
|
||||
InputManager.Instance.OnJumpEvent -= CurrentCharacterController.JumpInput;
|
||||
InputManager.Instance.OnAimToggleEvent -= CurrentCharacterController.AimToggleInput;
|
||||
InputManager.Instance.OnLookEvent -= CurrentCharacterController.LookInput;
|
||||
InputManager.Instance.OnDodgeEvent -= CurrentCharacterController.DodgeInput;
|
||||
//InputManager.Instance.OnNormalAttackEvent;
|
||||
//InputManager.Instance.OnHeavyAttackEvent;
|
||||
}
|
||||
|
||||
if(GameManager.Instance != null)
|
||||
{
|
||||
InputManager.Instance.OnKeyDown_IKeyEvent -= GameManager.Instance.InGameUI.InventoryToggle;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class InGameUIManager : BaseUIManager
|
||||
{
|
||||
public SplitWindowUI SplitWindowUI;
|
||||
public TooltipUI TooltipUI;
|
||||
public Transform DragCanvas;
|
||||
public GameObject InventoryRoot;
|
||||
|
||||
[SerializeField] private GameObject _crosshairRoot;
|
||||
|
||||
|
||||
|
||||
public void VisibleCrossHair(bool isOn)
|
||||
{
|
||||
_crosshairRoot.SetActive(isOn);
|
||||
@@ -19,4 +19,33 @@ public SplitWindowUI GetSplitWindowUI()
|
||||
{
|
||||
return SplitWindowUI;
|
||||
}
|
||||
|
||||
public void InventoryToggle()
|
||||
{
|
||||
InventoryOnOff(!InventoryRoot.activeSelf);
|
||||
}
|
||||
|
||||
public void InventoryOnOff(bool isOn)
|
||||
{
|
||||
InventoryRoot.SetActive(isOn);
|
||||
|
||||
if (isOn)
|
||||
{
|
||||
// UI 조작 모드로 변경 (캐릭터 이동 입력 차단)
|
||||
InputManager.Instance.ActiveOnlyOneActionMap("InGameUI");
|
||||
|
||||
// 커서 자유롭게 풀기
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 플레이어 모드로 복귀
|
||||
InputManager.Instance.ActiveOnlyOneActionMap("Character");
|
||||
|
||||
// 커서 중앙 고정 및 숨김
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
Cursor.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user