Project reset to previous state

While working on a quick prototype project, I encountered a problem that seems to be reported the forum several times. I set up a project in Unity 2022.1 using the URP 3D template, imported some packages and quite a bunch of bought assets (~2-3 GB estimated). I shut down Unity to eat something and wanted to setup a git afterwards. When reopening the project, almost all assets were gone and the project looked exactly like the template I used.

There are however, some interesting things:

  • The files are not in the recycle bin
  • I did not open the folder with any other software (SourceTree was assumed to the culprit once, but not in my case. I was just in the process of setting up Git)
  • In the project folder, all .csproj-files of assembly definitions from imported Asset store packages are still present. So they used to be there
  • The package manifest has been reset as well. All removed packages are back, all added packages are gone
  • ProjectSettings seem to be reset as well, but I can’t tell for sure, this I was just setting up this project

The Library folder still has a size of 5,34 GB while the Assets folder is a merely 124 Kb. I used the Unity Hub 3.3.0 to open the project. There was no MessageBox or any input required when opening the project for the second time. No special AV software is installed, just basic Windows 11 defender stuff.

This happened to me a couple of weeks ago on a different machine (Windows 10 in this case) but I assumed I did something wrong. In both cases it was the second opening of the project right after the setup in intention to clean up the project before doing the initial git push. Since it happened twice and others have reported similar problems (up to losing the whole “Documents” folder in windows), I expect some obscure bug doing it’s work.

I will try to recreate this during the next week, but for the moment I’ll assume that the Hub did not correctly recognize that my project was already set up and applied the project template again hence overwriting Assets, Packages and ProjectSettings but not the Library folder.

Does anybody know of a bug ticket for this stuff? How to even properly describe it (no native english speaker here)? Can anybody reproduce this or give some more ideas?

Lost progress / project / work / stuff disappeared in Unity.

This article is to help you when you have lost significant progress or work in your Unity project.

It is designed to give you avenues of discovery and investigation.

It is NOT a guarantee of restoring your lost work. It is NOT a substitute for proper IT / Data security procedures.

To decide which parts are applicable to you, look for major bolded headings.

EVERYTHING IS GONE, YOU CANNOT OPEN THE PROJECT

Your project probably is still on your computer. Try a computer-wide search for some unique filenames that you know are in the project you think is gone.

To start your search, one common file to all Unity projects is named ProjectSettings.asset

Some things that might have happened:

  • you are not opening the project that you think you are
  • you are in the correct project but not opening the same scene you had open before
  • you dragged the project (or part of it) into the trash (intentionally or inadvertently)
  • you moved the project (or part of it) somewhere else (intentionally or inadvertently)
  • an overly-aggressive antivirus solution quarantined it because it saw code being compiled in there
  • you’re using a directory sync like OneDrive or Dropbox… NEVER USE THESE SERVICES WITH UNITY!
  • something else??

As I said, it’s probably still all on your system to be found if you look in the right places.

A typical Unity project will have at a minimum the following folders:

ProjectSettings\
Packages\```

**EVERYTHING IS PRESENT BUT MY SCENE WINDOW IS BLANK**

Close Unity and make a full project backup RIGHT NOW. Do not do ANYTHING else until you back it up 100%.

Ideally copy that backup to another computer, or back it up to another external hard drive entirely. This is just basic data processing best practices during data recovery operations.

If you can see all the files and folders of your project, make sure you are opening the scene file you were working in.

Once you have opened the scene, look in the hierarchy window, select an object and move the mouse over the Scene window and press F to focus that object.

Additional notes:

- ALWAYS use proper industrial grade source control (see below)
- NEVER use Dropbox or any file sync mechanism in Unity.
- NEVER move files within your project, except by doing it within Unity
- ALWAYS be sure you are fully backed up before upgrading Unity

**SCRIPTS OR ASSETS ARE MISSING OR BLANK**

Some info about Missing script warnings, broken prefabs, GUIDs, renaming GUIDs, etc:

https://discussions.unity.com/t/836322/2
https://discussions.unity.com/t/815173/7
https://discussions.unity.com/t/815173/9

EVERYTHING in Unity is connected to the above GUID, which is stored ONLY in the metafile.

It is super-easy to inadvertently change it by renaming outside of Unity. Don't do that. Instead:

- close Visual Studio (important!)
- rename the file(s) in Unity
- in Unity do Assets -> Open C# Project to reopen Visual Studio
- now rename the actual classes, and MAKE SURE THE FILE NAMES DO NOT CHANGE!

If you are NOT using source control while you do this, renaming files is an EXTREMELY dangerous process. Use source control at all times so that you can trivially revert if you miss a critical step and damage your project.

I'm sorry you've had this issue. Please consider using proper industrial-grade enterprise-qualified source control in order to guard and protect your hard-earned work.

Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).

You can also push git repositories to other drives: thumb drives, USB drives, network drives, etc., effectively putting a complete copy of the repository there.

As far as configuring Unity to play nice with git, keep this in mind:

https://discussions.unity.com/t/736093/3

Here's how I use git in one of my games, Jetpack Kurt:

https://discussions.unity.com/t/807568/3

Using fine-grained source control as you work to refine your engineering:

https://discussions.unity.com/t/826718/2

Share/Sharing source code between projects:

https://discussions.unity.com/t/719810/2

Setting up an appropriate .gitignore file for Unity3D:

https://discussions.unity.com/t/834885/5

Generally setting Unity up (includes above .gitignore concepts):

https://thoughtbot.com/blog/how-to-git-with-unity

It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place. Digital storage is so unbelievably cheap today that you can buy gigabytes of flash drive storage for about the price of a cup of coffee. It's simply ridiculous not to back up.

"Use source control or you will be really sad sooner or later." - StarManta on the Unity3D forum boards

I you have took the time to read my post beyond the title, you would have read that I have checked the folder, the Library folder has the correct size and remnants of the assembly definition are still present. As a professional with more than two decades of experience and more than a decade in working with unity, I know about source control, folder structures … in short: I’m not beyond making mistakes, but I know my stuff and your superficial copy&paste text (which I’ve seen before) does not help. I would greatly appreciate if you read my posting again and try to help then.

There is no Dropbox involved, no external tool or git was used up to this point (it would have been a couple of minutes later). Nothing of value - apart from my time - was lost.

1 Like

I had this issue 2 times a few months back, was beyond teriffying

Just made new project, added stuff, closed Unity, to find only the template when reopen. All traces of my stuff gone also, nothing in recycle bin etc

I still worry every single time i open a project that all will be lost, though have not seen this again lately

None of those will help in this case, files are just gone.

Unity should check to remove all code that resets files in Assets, i would say this is a critical bug to be fixed immediatly.