# 无效操作异常：在输入操作资源'Controls'中未找到输入操作映射'Gameplay'。

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

## 根因

代码引用了一个在分配的输入操作资源中不存在的输入操作映射名称。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.4 | active | — | — |
| 1.5 | active | — | — |
| 1.6 | active | — | — |
| 1.7 | active | — | — |

## 解决方案

1. ```
   Open the InputActionAsset (e.g., 'Controls.inputactions') in the editor, verify the map name is 'Gameplay', and correct the code: InputActionMap gameplayMap = inputAsset.FindActionMap("Gameplay"); If the map is named differently, update the string.
   ```
2. ```
   Use FindActionMap with a fallback: var map = inputAsset.FindActionMap("Gameplay") ?? inputAsset.FindActionMap("Default"); This prevents crashes but may not bind the correct actions.
   ```
3. ```
   Regenerate the InputActionAsset from a template that includes the missing map: right-click > Create > Input Actions, then copy the map structure from the old asset.
   ```

## 无效尝试

- **** — Random names never match the asset; the name must exactly match the one in the .inputactions file. (90% 失败率)
- **** — This loses all existing bindings and requires reconfiguring controls, which is overkill for a missing map name. (40% 失败率)
- **** — ListEnabledActions returns actions, not maps; it does not help locate the correct map name. (70% 失败率)
