업무_메모

[Unity] InvalidOperationException: Input.GetKey 사용 시 오류 해결

shine94 2025. 4. 17. 19:58

* Unity 2019.1부터는 새로운 Input System 패키지가 도입되면서,

   기존의 Input.GetKey, Input.GetAxis와 같은 Legacy Input API는 기본적으로 차단된다

   따라서, 기존 방식을 사용하려면 추가 설정이 반드시 필요하다

 

 

🧨 발생했던 에러 메시지

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.
UnityEngine.Input.GetKey (UnityEngine.KeyCode key) (at <1bcf3db9368d4289aae60d04194b7157>:0)
PlayerController.Update () (at Assets/Script/Managers/PlayerController.cs:15)
 

 

🔍 원인

아래와 같이 설정되어 있는 경우, Input.GetKey와 같은 기존 Input 클래스를 사용하면 오류가 발생한다

Edit > Project Settings... > Player > Active Input Handling > Input System Package (New)

 

 

✅ 해결 방법

Edit > Project Settings... > Player > Active Input Handling > Both로 변경