# NavMeshObstacle：启用了雕刻模式但障碍物未移动。如果障碍物是静态的，可能会导致性能问题。

- **ID:** `unity/navmesh-obstacle-carve-not-moving`
- **领域:** unity
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

NavMeshObstacle 组件在静态对象上启用了雕刻模式，导致不必要的导航网格雕刻更新，从而降低性能。

## 版本兼容性

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

## 解决方案

1. ```
   Disable Carve mode on static obstacles: Select the GameObject, in the NavMeshObstacle component, uncheck 'Carve'. Use this code snippet to automate: GetComponent<NavMeshObstacle>().carving = false;
   ```
2. ```
   If the obstacle is intended to move, attach a script that toggles carving on movement: void Update() { if (transform.hasChanged) { GetComponent<NavMeshObstacle>().carving = true; } else { GetComponent<NavMeshObstacle>().carving = false; } }
   ```

## 无效尝试

- **Disable and re-enable the NavMeshObstacle component at runtime** — This does not change the Carve mode setting and the static obstacle still triggers carving warnings. (90% 失败率)
- **Increase the carving update interval in NavMesh settings** — The warning is about the mode being inappropriate for static objects, not about update frequency. (85% 失败率)
