InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings


문제 내용

Project 를 생성하게 되면 기본적으로 Input System 이 Input Manager 로 설정 되는것을 확인할 수 있다. (2021.3.13f1 Standard 기준) 

 

관련해서 확인해아 하는 부분은 다음과 같다

  • Input Manager : [Edit] - [Project Settings] - [Input Manager] 

 

  • Active Input Handling* : [Edit] - [Project Settings] - [Player] - [Other Setting] - [Configuration] - [Active Input Handling*]

위의 정보가 기본 설정 값인데

여기서 새로 추가된 Input System Package 라고 Package Manager 에서 설치하게 되면 

Input System이 기존의 Input Manager와 Input System으로 두 가지가 되는 상황이고 

여기서 Input System Handling 옵션을 어느 하나로 지정했을 경우 충돌이 생기는 현상으로 판단된다.


증상

 

만약 Active Input Handling* 정보가 다음과 같이 

Input System Package (New)로 설정되있다면

Input Manager 정보가 변경되 있다는 것을 확인할 수 있다. 

입력 처리가 Input system package로 전환되서 Input manager가 사용되지 않는다는 내용이며

이 상태에서 기존에 사용했던 형태로 Input 기능을 사용하면 해당 Error 가 발생한다. 

public class TestInput : MonoBehaviour
{
    void Update()
    {
        if(Input.GetKey(KeyCode.A))
        {
            Debug.Log("A");
        }
    }
}

Error 발생


해결 방법

Active Input Handling 값을 Both로 설정 한다. 

-> [Edit] - [Project Settings] - [Player] - [Other Setting] - [Configuration] - [Active Input Handling*] - [Both]


참고자료

+ Recent posts