# IL2CPP 错误：Managed/UnityEngine.dll 不可用于代码生成。这可能是因为 IL2CPP 后端缺失或损坏。

- **ID:** `unity/il2cpp-codegen-managed-backend-unavailable`
- **领域:** unity
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

IL2CPP 代码生成后端无法找到托管的 UnityEngine.dll，通常是由于 Unity 的 IL2CPP 支持包安装不完整或损坏。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Unity 2021.3.0f1 | active | — | — |
| Unity 2022.3.0f1 | active | — | — |
| Unity 2023.2.0f1 | active | — | — |
| Unity 2024.1.0b1 | active | — | — |

## 解决方案

1. ```
   Reinstall the IL2CPP package via Unity Hub: Open Unity Hub, select the project's Unity version, click 'Manage Modules', ensure 'Windows Build Support (IL2CPP)' or equivalent is checked, then apply changes.
   ```
2. ```
   Manually repair Unity installation by running the Unity installer's repair option: Uninstall Unity version via Control Panel, then reinstall from Unity Hub with IL2CPP support included.
   ```

## 无效尝试

- **Reimport all assets via Assets -> Reimport All** — Reimporting assets does not repair the IL2CPP backend installation; it only refreshes asset metadata. (95% 失败率)
- **Delete Library folder and restart Unity** — Deleting Library removes cached data but does not fix missing IL2CPP components in the Unity installation. (80% 失败率)
- **Switch to Mono scripting backend and back to IL2CPP** — This may trigger a rebuild but does not address underlying corruption of the IL2CPP package. (70% 失败率)
