unity
io_error
ai_generated
true
AssetDatabase.Refresh 失败:无法刷新资源 'Assets/Resources/data.asset',因为文件被另一个进程锁定。
AssetDatabase.Refresh failed: Could not refresh asset 'Assets/Resources/data.asset' because the file is locked by another process.
ID: unity/assetdatabase-refresh-failed-locked-file
85%修复率
88%置信度
1证据数
2023-02-18首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Unity 2020.3.0f1 | active | — | — | — |
| Unity 2021.3.0f1 | active | — | — | — |
| Unity 2022.3.0f1 | active | — | — | — |
| Unity 2023.2.0f1 | active | — | — | — |
根因分析
项目 Assets 文件夹中的文件被外部程序(例如版本控制、文本编辑器或防病毒软件)锁定,阻止 Unity 在刷新期间读取或写入它。
English
A file in the project's Assets folder is locked by an external program (e.g., version control, text editor, or antivirus), preventing Unity from reading or writing it during refresh.
官方文档
https://docs.unity3d.com/ScriptReference/AssetDatabase.Refresh.html解决方案
-
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).
-
Exclude the Unity project folder from antivirus real-time scanning to prevent locks. Then restart Unity and perform a refresh.
无效尝试
常见但无效的做法:
-
Run Unity as administrator
80% 失败
Administrator privileges do not unlock files held by other processes; the lock persists.
-
Delete the locked file and recreate it
70% 失败
Deleting may succeed but the new file can be locked again if the external process is still running.