# InvalidOperationException: 无法读取动作'Jump'的值，因为动作映射'Gameplay'未启用

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

## 根因

包含该动作的输入动作映射在尝试读取其值之前未启用，通常是因为未对映射或InputActionAsset调用Enable()。

## 版本兼容性

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

## 解决方案

1. ```
   在Awake()或Start()中启用动作映射，然后再读取任何输入：inputActionAsset.FindActionMap("Gameplay").Enable(); 或使用inputActionAsset.Enable()启用所有映射。
   ```
2. ```
   如果使用PlayerInput组件，在检查器中设置默认映射为所需映射，并确保组件在游戏对象上已启用。
   ```
3. ```
   在每个动作上设置回调后使用InputAction.Enable()，但确保父映射也已启用以避免冲突。
   ```

## 无效尝试

- **** — Overrides bypass the normal input flow and can cause stale values or conflicts with actual input devices. The action map still remains disabled. (90% 失败率)
- **** — This defeats the purpose of using action maps for contextual input (e.g., UI vs Gameplay) and may break input switching logic. (85% 失败率)
- **** — Enabling individual actions without the parent map can lead to inconsistent state and may not register input correctly if the map is disabled. (80% 失败率)
