# AssetDatabase.Refresh 失败：无法刷新资源 'Assets/Resources/data.asset'，因为文件被另一个进程锁定。

- **ID:** `unity/assetdatabase-refresh-failed-locked-file`
- **领域:** unity
- **类别:** io_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

项目 Assets 文件夹中的文件被外部程序（例如版本控制、文本编辑器或防病毒软件）锁定，阻止 Unity 在刷新期间读取或写入它。

## 版本兼容性

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

## 解决方案

1. ```
   Identify and close the locking process: Use tools like Sysinternals Handle.exe to find which process has a lock on the file. In Command Prompt: handle.exe -a "Assets/Resources/data.asset" then close the identified application (e.g., Notepad++ or Git).
   ```
2. ```
   Exclude the Unity project folder from antivirus real-time scanning to prevent locks. Then restart Unity and perform a refresh.
   ```

## 无效尝试

- **Run Unity as administrator** — Administrator privileges do not unlock files held by other processes; the lock persists. (80% 失败率)
- **Delete the locked file and recreate it** — Deleting may succeed but the new file can be locked again if the external process is still running. (70% 失败率)
