- Home /
recover script instead of autosave?
when opening my script it asked me if I wanted to open it or the autosave it found. The auto save is the one I opened, but apparently was the wrong one and missing a LOT of my code. Is there any way to get the last save of it instead? I do have a build version with the exe and _data folder, but no idea how to turn that back into my scripts.
Answer by Bunny83 · Aug 17, 2012 at 05:50 PM
If the code in question doesn't contain coroutines, you can use ILSpy to decompile the assemblies from your build to C#. Just open the assemblies in ILSpy and extract the code. It can of course recover UnityScript - scripts as well, but only as C# code ;) AFAIK there is no UnityScript decompiler out there since UnityScript is an artificial language which only exists in Unity.
Just take a look into your _Data folder: _Data/Managed/
The dlls that start with "Assembly-" contains your scripts
edit
If you have trouble to get it working, upload your assemblies somewhere and post them here. I can extract them for you, but's it's actually not that hard ;)
FREA$$anonymous$$IN' AWESO$$anonymous$$$$anonymous$$ Thanks, I had some trig variables in there that were a pain to work out the first time. I originally wrote in JS, but it's not that hard to switch back over to somthing I've already done if I have the layout back. Once again, thank you!
If this works for me I am probably going to kill myself of pure joy.
EDIT: I just finished using ILSpy and I'm setting up the noose right now. Thank you so much!
Thank you for this! I do back up my project,however not frequently enough. This saved me re doing a days work of coding
Nice! It also works on projects you haven't built yet but Unity has compiled in the editor. Check PROJECT_PATH/Library/ScriptAssemblies/Assembly-CSharp.dll and its variants for Editor scripts and plugins.
CAUTION: do not reopen / focus on Unity / refresh your assets, it would recompile the code, causing you to lose the dll! Fortunately, if you have really lost a lot of code, it is likely that a class is missing, preventing Unity from recompiling. Grab that chance and make a copy of your DLLs immediately.
$$anonymous$$y problem wasn't as terrible as the others: thanks to Git stashing I kept a copy of my work of the last hour. That said, $$anonymous$$onoDevelop (combined with Unity trying to recompile I guess) deleted my file without warning and I closed the tab containing the code in RA$$anonymous$$ just at that moment. ILSpy allowed me to remember what I had done, even if comments and original variable names were removed.
Answer by Kryptos · Aug 16, 2012 at 01:02 PM
Consider using a version control system such as Subversion or Git (which are both free). And do regular backups of your project.
That's a good idea for future issues, but does that mean I can't get back what was lost?
Looks like you can't recover what you lost if it is not in the autosave file.
I should have assumed I saved the version I needed and not worried about the autosave. oh well. I have some idea of whats missing.
Answer by PDay · Sep 26, 2018 at 08:27 PM
I just had this, and it deleted my local git as well which was in the same directory (lesson learnt). I also didn't have the assembly file, however, I did have a recent build of my game (the night before), you can find a copy of the Assembly-CSharp.dll in the _Data/Managed folder.