Skip to content

Input System

Yunseong Jeong edited this page Nov 1, 2024 · 3 revisions
  • InputManager

    • Description
      • 입력을 관리하고, 키 상태 확인, 키 매핑 관리, 키 이벤트에 대한 리스너 알림 기능을 제공합니다.
    • Method
      • bool isMoveActioncode(ActionCode action)

        • description
          • 지정된 액션 코드가 이동 동작을 나타내는지 확인합니다.
        • param:
          • action (ActionCode) 확인할 액션 코드입니다.
        • return:
          • 이동과 관련된 액션이면 true (예: MoveUp, MoveDown), 아니면 false를 반환합니다.
      • void SetKeyActive(ActionCode action, bool active)

        • description
          • 지정된 액션 키의 활성 상태를 설정하여 해당 입력을 활성화하거나 비활성화합니다.
        • param:
          • action (ActionCode): 설정할 액션 코드입니다.
          • active (bool): true로 설정하면 활성화, false로 설정하면 비활성화됩니다.
      • void SetMovementState(bool active)

        • description
          • 모든 이동 관련 액션을 활성화하거나 비활성화합니다.
        • param:
          • active (bool): 이동 액션을 활성화하려면 true, 비활성화하려면 false를 설정합니다.
      • bool GetKeyActive(ActionCode action)

        • description
          • 특정 액션 키의 활성 상태를 반환합니다
        • param:
          • action (ActionCode): 확인할 액션 코드입니다.
        • return:
          • 키가 활성화되어 있으면 true, 그렇지 않으면 false를 반환합니다.
      • void SetKey(ActionCode actionCode, KeyCode newKey)

        • description
          • 특정 액션에 새로운 키를 매핑합니다.
        • param:
          • actionCode (ActionCode): 매핑할 액션 코드입니다.
          • newKey (KeyCode): 새로 할당할 키 코드입니다.
      • bool GetKeyDown(ActionCode action)

        • description
          • 지정된 키가 해당 프레임에서 눌렸는지 확인합니다.
        • param:
          • action (ActionCode): 확인할 액션 코드입니다.
        • return:
          • 키가 눌렸다면 true, 그렇지 않으면 false를 반환합니다.
      • Vector3 GetMoveVector()

        • description
          • 현재 입력에 따라 움직임 방향을 나타내는 Vector3 값을 반환합니다.
        • return:
          • 움직임 방향을 나타내는 Vector3 값입니다.
      • bool GetKey(ActionCode action)

        • description
          • 지정된 키가 현재 눌려있는지 확인합니다.
        • param:
          • action (ActionCode): 확인할 액션 코드입니다.
        • return:
          • 키가 눌려있으면 true, 그렇지 않으면 false를 반환합니다.
      • void SetInputListener(IInputListener listener)

        • description
          • 입력 이벤트를 수신할 리스너를 등록합니다.
        • param:
          • listener (IInputListener): 추가할 리스너입니다.
  • IInputListener (interface)

    • method
      • void OnKeyDown(ActionCode action)

        • description
          • 지정된 액션이 눌렸을 때 호출됩니다.
        • param:
          • action (ActionCode): 눌린 액션 코드입니다
      • void OnKey(ActionCode action)

        • description
          • 지정된 액션이 눌려 있는 동안 호출됩니다.
        • param:
          • action (ActionCode): 눌린 액션 코드입니다
      • void OnKeyUp(ActionCode action)

        • description
          • 지정된 액션이 떼어졌을 때 호출됩니다.
        • param:
          • action (ActionCode): 눌린 액션 코드입니다
  public class TestClass : MonoBehaviour, IInputListener {
    void Start(){
        InputManager.Instance.SetInputListener(this);
    }
    void IInputListener.OnKey(ActionCode action) {
        if (action == ActionCode.SelectClick){
            // SelectClick 실행 시에 실행 되어야하는 코드
        }
    }
    }