- Home /
Why don't project window changes persist after a crash?
For example I changed one of my prefabs attached scripts prior to a crash I just had. The prefab is not in scene, it's in the project window, on the disk. Why doesn't a change to a file like that persist after a crash? After reloading my project and hitting start I get a null reference error because the script isn't on the prefab. I also lose shader tweaks and other public variable changes that aren't related to the scene.
Is that the difference between the "save project" and "save scene" options? Does "save scene" automatically call "save project"? I hit ctrl+s all the time, it just seems like a crash will still wipe out certain changes. Thankfully crashes are few and far between for me, but I don't understand why files on disk revert to their previous state.
Yes, there is a difference between "Save Project" and "Save Scene": some changes, usually overall project related like those in the settings assets, only get saved when you click "Save Project". However, although "Save Scene" does NOT call "Save Project" (and I think it should), it does save some changes not related to scenes. Unfortunately, there doesn't seem to be any documentation regarding when different elements are saved.
Note that there are also some changes that only get saved when you exit the Editor (for example layout of the different views) - these are usually Editor related changes.
So in general, it is a good idea to save often (ctrl+s), even if you are modifying a prefab in the Project view (and hoping that this will work), and manually use "Save Project" every now and then.
What you say that a change to a prefab in the Project view did not get "saved", even though the changes are present in the file seems to indicate that the crash might have occurred while saving, corrupting the prefab file or the asset database. You could try to reproduce the issue and create a bug report.
Answer by malkere · Sep 06, 2018 at 08:15 AM
https://docs.unity3d.com/Manual/Saving.html Sometimes (usually) we skip over the easy stuff. Written pretty plainly in the manual though.
"To save changes to the scene, select Save Scene from the file menu, or hit Ctrl/Cmd + S. This saves current changes to the scene and Does a “Save Project” (below)."
I guess I just hadn't ctrl+s'd in a while because I wasn't working on scene data.