Deleted files reappear

I have this weird problem that sometimes when I delete files in the Editor Project window, they will magically re-appear after a minute or so. It has something to do with meta files I guess.

Perhaps related but sometimes when I rename a cs file and start modifying the code, the code I written gets deleted and replaced by the file as it was just before I renamed the file. That one is particular annoying because it deletes my code without warning!

I googled around a bit for this but I find nothing which to me is quite shocking. I would like to file a bug report but it is not easily reproducible.

Anyone else having these problems?

I have this all the time, it’s so irritating. I think there are two cases when it happens.

First is like what you described. When I rename a .cs file in the Project view while it’s still open in Visual Studio, if I save it again in VS, it doesn’t detect that the name changed so it gets saved again under the old name.

The other case is when I delete directories. It disappears at first, but then sometimes comes back when I later reopen the project. I thought this had to do with the .meta files, but when I manually delete these as well, it still sometimes reappears. I suspect it may have to do with the Temp folder, can anybody confirm?

Something similar happened to me a couple of times. How I fix this, is I delete everything except Assets and ProjectSettings folders from my project folder. When I then launch Unity, it rebuilds everything and the problem is gone.

P.S. Don’t forget to make a backup copy before doing this.

Thanks, will try that.

getting this now, any ideas how to fix?

It’s what @Devil_Inside said. Delete the folder that you don’t want and close Unity quickly before it can re-appear. Once Unity is closed, make a back-up of your project. Then delete the library folder from your project. Open Unity again and it should be gone for good.

The back-up is for if you accidentally delete something that breaks your project.

1 Like

great thanks.

Forgot to mention: when you reopen Unity, Unity will rebuild the library from the files in your assets folder. It will take some time, depending on how big your project is.

This seems like a very hacky solution. After deleting my Library folder it takes about 30 minutes to rebuild everything. Is there no other way to get around this or disable this “feature”? I use git so I see that there are new unstaged files, but I have to take extra care when e.g. adding a new asset and staging a bunch of new files to not stage/commit these previously deleted files.