I read through the threads on this already, and I think this warrants some investigation:
I’m using Unity 2021.1.16f1 with Visual Studio Integration 2.0.11, Visual Studio 2021 Preview, Unity Hub 2.4.5. A couple of things first:
- I CTRL-S constantly
- I ensured I had no dirty windows before closing Unity
- I closed Visual Studio before closing Unity
- No source control was active on the project or any child folder
I tried to attach to Unity to debug a script. I got a dialog box saying “Unspecified Error” and was unable to debug. I tried several times, saving, closing Visual Studio and re-launching, but no luck. I had other things to get to.
In this order:
-
I closed Visual Studio. When I shut down Visual Studio, I ensured that all my windows were clean - all changes were committed to disk
-
I manually saved the scene in Unity and closed the editor without any warnings
Some time passed. I re-opened my project through Unity Hub (as usual). The project opened as if I had just started a new project from Unity Hub.
- All assets I had created including scripts and prefabs were deleted
- All package changes I had made (imports, updates) had been reverted
- The /_Temp folder in my project was cleared
Interestingly, the .csproj file I had generated when working in Visual Studio was still present. Opening the project file directly in Visual Studio clearly shows what the contents should be, but Visual Studio reports that the files are no longer present.
This affected both files that were open in either editor, as well as files that were not:
To be clear, this appears to be a scorched-earth overwrite of the entire project folder with a completely clean, new template.
A few observations:
-
If this was a file-handle / lock issue, it would only affect open files. Since this is not the case, I believe this explanation is out.
-
The package manifest.json file was overwritten. Of particular interest, all added packages were removed, and the specific upgrade of “com.unity.ide.visualstudio”: “2.0.9” to “com.unity.ide.visualstudio”: “2.0.11” was reverted. Additionally, the packages-lock.json was reverted.
-
The Assets folder’s Date Created and Date Modified were reverted to both be the exact same date and time I tried to re-open the project. The SampleScene.unity and SampleScene.unity.meta in the Assets/Scene folder had their Date Created set to the same time, but their Data Modified was reverted to 4/17/2020 @4:35 AM.
Based on this, I can draw a couple of conclusions:
-
This is not a file lock issue: it affected all files in the project, open or not as well as reverting changes to dates and times on folders and files created during project scaffolding
-
This is not a source control issue: no source control mechanism was in place
-
Visual Studio was closed before Unity was closed. Since Unity did not report any errors while I was saving my work, I can conclude the Visual Studio was not involved in the project corruption. This is further supported by the fact that artifacts specifically in use by Visual Studio (the .csproj files) are intact and in the correct state.
-
This was not a result of a reported error in Unity3D. Shutdown was clean and reported no errors. Attempting to save a locked file would result in a lock violation in Windows. A search in Event Viewer for any errors related to the Unity3D app yields no results.
Given the above, I strongly suspect that there is an issue in the Unity Hub project launcher that resulted in my project being re-created. Any files or folders present in the template are cleanly overwritten including OS files system metadata. This did not result in my .csproj files being overwritten because those files are only touched when Unity is configured to generate them, and you either click the ‘regenerate’ button, or shell out to Visual Studio to edit a script. They would not be present when being copied from the template.
I’m happy to provide any additional information I can. Hopefully someone will be able to use this to locate this bug.
I did notice that my time zone on my system updated today. I don’t know if that would be significant or not. Good luck bug hunting!
Jules
7423133–908480–manifest.zip (1.39 KB)
7423133–908483–SampleScene.zip (2.44 KB)