2
\$\begingroup\$

I accidentally deleted my game. I had been working on it for about 2 months and I accidentally deleted it while cleaning up my files. I am so smh. I have a ton of builds of the game though and since the game and all its scripts were converted to a file. Would I be able to un-pack said build back into a Unity project? I am not that cut about the game because I didn't like it but I did spend a lot of time on it. Oh yeah and also it was a school assignment.

\$\endgroup\$

4 Answers 4

7
\$\begingroup\$

No, you cannot unpack a Unity build into the source files for the project.

You can decompile the managed assemblies to get equivalent C# code out of them, but it won't be exactly the code you wrote. It will likely be mangled and harder to read, lacking comments etc.

You can try to extract assets like textures too, but you won't get your original files back. In order to make them fast to load and efficient to display on graphics hardware, Unity converts files to GPU friendly formats and applies various compression strategies to them as part of the build process. This can be lossy — the texture you get at the end is not necessarily a pixel-for-pixel match with the input image.

If you have one specific script you don't remember how to write, or one specific image asset you can't re-make, then these strategies might be worthwhile to get a starting point you can then edit by hand back to what you want it to be.

But for most purposes, you'll be better off remaking the project from scratch, using what you learned the first time around to do it better this time.

One such lesson should be to use a version control system and keep a backup somewhere so you never land in this situation again.

\$\endgroup\$
5
  • \$\begingroup\$ How would I be able to decompile/extract "assemblies" to get said c# code out of them? I did some quick searching and turned up empty handed other then this forum.unity.com/threads/…. Also that's a shame that I cant re-convert it and also not a shame at the same time because its good that unity is compressing the daylights out of all files so my games are smaller in size. \$\endgroup\$ Commented May 8, 2021 at 12:33
  • 1
    \$\begingroup\$ Top search hits for "unity decompiler" turn up this tool, which promises to decompile a whole Unity project, though it doesn't appear to have been updated since version 5.6. You can also use generic C# decompilers on the .dll files in your builds. \$\endgroup\$ Commented May 8, 2021 at 12:39
  • \$\begingroup\$ All of this decompiling stuff hurts my head. I cant afford to loose my sanity anytime soon. I'll just work on my new game that I'm developing for now and give it another crack in the future. Thanks for the help! I really appreciate it but I wont accept it as an answer yet until I actually get my scripts decompiled. \$\endgroup\$ Commented May 9, 2021 at 11:01
  • \$\begingroup\$ I accidentally deleted another game. Wow. \$\endgroup\$ Commented Jun 23, 2022 at 12:07
  • 3
    \$\begingroup\$ "One such lesson should be to use a version control system and keep a backup somewhere so you never land in this situation again" — this will keep happening until you learn this lesson. \$\endgroup\$ Commented Jun 23, 2022 at 12:08
1
\$\begingroup\$

Yes, you can. Try programs like AssetRipper (which's a fork of uTinyRipper program).

How well these programs cope with unpacking depends on the unity version, the older it is, the better.

\$\endgroup\$
0
\$\begingroup\$

Yes there are tool nowadays like assetripper and some mono assembly decompiler but the problems will soon rise when your trying to decompile the asset bundles and shader which is currently possible but very far to be stable to be used on your decompile project and you may need on expertise on rebuilding the shader based on my experience may differ on later unity builds

\$\endgroup\$
-2
\$\begingroup\$

No, you cannot directly convert a built Unity game back into a Unity project. However, it is possible to decompile the game's code. When a Unity game is built, the C# scripts are compiled into .NET assemblies, which can be decompiled back into readable C# code using tools like ILSpy or dotPeek. Once decompiled, the code can be modified and recompiled, but this process won’t give you the original Unity project structure (scenes, assets, settings, etc.), only the scripts.

Bear in mind that proper games often implement security measures, such as integrity checks or hash verifications, to detect changes in the code and prevent tampering. However, some games don’t have these protections, making it easier to alter the code.

Another approach to modify games is using tools like Cheat Engine, which allows you to read and modify memory addresses while the game is running. This can affect variables like health, currency, or other in-game values.

That said, I would caution against doing this. Depending on your goal, it could involve unethical behavior, such as cheating or attempting to reverse-engineer and reuse someone else's work without permission. This would likely violate the game's terms of service and could even be illegal, especially if you're using someone else's code to build your own project.

In short, while it's technically possible to decompile and modify Unity games, you should consider the ethical and legal implications before proceeding.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ This appears to address concerns that are not outlined in the Question. \$\endgroup\$ Commented Oct 25, 2024 at 14:52

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.