- Home /
Cannot delete asset with AssetDatabase.DeleteAsset?
when I try to delete .asset I get this error:
Failed to remove asset meta data because some of its object's were still loaded!
here's the code:
public void CopyCurrentStorage(string stPath, string path, string name){
string toPath = path +"/" +name +".asset";
if(System.IO.File.Exists(Application.dataPath +"/" +toPath))
Debug.Log(AssetDatabase.DeleteAsset(toPath));
//if(AssetDatabase.DeleteAsset(toPath))
// AssetDatabase.CopyAsset(stPath, toPath);
else AssetDatabase.CopyAsset(stPath, toPath);
AssetDatabase.Refresh();
}
How could I 'unload objects' from .meta? (Deleting from editor with pressing [del] works fine)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613165410im_/https://answers.unity.com/themes/thub/images/avi.jpg)