# InvalidOperationException：InputAction 'Player/Move' 未启用。无法读取值。

- **ID:** `unity/input-system-action-not-found`
- **领域:** unity
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 92%

## 根因

在 InputAction 启用之前（例如在 InputSystem.EnableDevice 或操作映射激活之前）通过 ReadValue() 读取该操作。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Unity 2022.3 | active | — | — |
| Unity 2023.1 | active | — | — |
| Unity 2021.3 | active | — | — |
| Input System 1.6.0 | active | — | — |

## 解决方案

1. ```
   Enable the action map before reading values: `InputActionMap actionMap = inputActions.FindActionMap("Player"); actionMap.Enable();` then call `inputActions.FindAction("Move").ReadValue<Vector2>();`
   ```
2. ```
   Use event-based callbacks instead of polling: `inputActions.Player.Move.performed += ctx => { Vector2 value = ctx.ReadValue<Vector2>(); };`
   ```
3. ```
   Delay the first read until after InputSystem.Update() by checking `InputSystem.isInitialized` and using a coroutine.
   ```

## 无效尝试

- **** — Calling Enable() on the action inside Start() or Awake() may still fail if the InputSystem hasn't initialized yet. (30% 失败率)
- **** — Disabling and re-enabling the action map in Update() causes repeated overhead and doesn't fix timing. (50% 失败率)
- **** — Using InputAction.ReadValue<float>() without checking isPressed first can still throw if not enabled. (60% 失败率)
