This post has been reblogged from my own blog at http://wajahatkarim.com.
So, after 2 days, today I started Unity3D to work on my current game. It started good, but what I saw was that there was nothing on the scene and there was not even a file in Assets folder. Following is the image of my assets folder when I initially saw the error.
I was shocked to see it, because my work of about 3 weeks was gone. I couldn’t see anything, I couldn’t do anything at all. This same error occurred to me a few days ago, but that time I had my code committed on BitBucket (http://www.bitbucket.org), so I restored backup from it and started working on it. But, today I had no backup, so I started searching about this bug over internet and Google. And I became very sad to see that lots of developers have faced from this problem, and there was no solution at all. Following are some links I found while searching:
All these links have few suggestions but there is not specific solution to this problem. And that’s really sad. After about an hour of experimenting with the folders and copy folders of my project, I resolved the bug and compiled the project successfully. In this post, I am writing about that issue below and its solution as well.
Timestamps (1279) and assets (1283) maps out of sync. occurred. All folders and files in the Assets folder is gone and doesn’t show up in Unity3D. And every game object is missing all components, scripts, and so on.
Possible Reasons for Occurrence
Well, I can’t tell you why exactly this problem occurs and why it happens. But, from my experience and material found on Internet, I can tell you that this problem occurs due to not closing Unity project safely. If your project is open, and there are some changes which are not saved yet in the scene or in any code files (* sign will appear with the name of file in Windows OS), and your laptop or computer shuts off suddenly due to power issue, or you just turn it off by holding power button (as I did ), or you face Blue Screen Of Death (BSOD) issue. Following image shows BSOD example on Windows OS. These some situations can make your hard work project corrupted in a matter of minutes, so always be careful in saving your work and properly close Unity and always keep a backup in version control or any other way you prefer.
Blue Screen of Death (BSOD) Windows OS
Other Solutions on Internet
I was instructed to delete Library folder and reload the project from following link:
It did the work, and all assets got reimported in Unity, but I was faced with another problem. All the game objects in the scenes are missing everything from Sprites in Sprite Renderers, Scripts, Shaders, Textures, references to other game objects and everything was messed up. And I couldn’t run the project at all. Following is sample image which shows the situation. So, I was again confused about it, then I did some experiments on the folder I was left with, and I finally did it successfully.
What I did was pretty easy and simple. I simply opened Assets folder in Windows Explorer, and copied all the contents from it. Then I created a new Unity project, and pasted all contents in Assets folder. Unity imported all assets, and then it started working. But, like all the solutions, there were some limitations to this which I had to manually set with some time-consuming efforts. But, I am glad my project was not lost and it is running smooth and shiny.
We sort of created a new project, so one limitation of this solution is that all the project settings such as Layers, Tags, Sorting Layers, Physics2D Settings, Input, Shader Settings etc have gone. So, you have to manually create all the settings in new project. What I did was that I had my old corrupted project, it hadn’t any assets linked, but it had project settings in it. I saw from it, and manually adjusted in new project. It made me open unity projects each 2 minutes, as Unity doesn’t allow to open multiple instances at same time.
Summarizing whole stuff, I have following precautions for you:
- Always keep your project in version control and keep it committed for backup
- Never instantly close system when Unity is running. Close unity first with saving or not saving changes, and then close system in way you like.