De-Compiling Unity Games

De-Compiling Unity Games

Before we start:

Do not use this to pirate games or build them and publish them with a slight change. De-compiling games and importing them back into Untiy might also break the terms of service of some games like Phasmophobia. You have been warned.

Now that that's over with though, lets begin.

Part One: Where Do I Even Start?

So slight fun story, I only figured this out because I wanted to dump the music of a unity game. Anyways.

First off you're going to need unity. Grab Unity hub from the website and install it. Now, for this example I'm going to use a free game on itch.io mainly because I don't want to get dunked on by some random game developer. The game I am going to be de-compiling is Five Night's At Freddy's In Unity.

Go ahead and download AssetRipper. This tool is going to do all the heavy lifting for us and make our life a lot easier. Once you've extracted the latest release into a folder.

Once you've got the program open. Drag and drop the game folder in like this. AssetRipper should detect everything automatically.

Once its loaded and done everything. Click on the unity version in the top left and select download. Here it says "Unity 2020.3.18" but it could vary from game to game. Once the unity webpage has loaded, click on the "install this version with Unity Hub" text and it should automatically install that version of Unity in Unity Hub. You don't need anything fancy / extra added with the unity installation so just click next until it starts installing.

0:00
/

While its installing the Unity version, go back to asset ripper and click on export. This is going to export all the game files from the game as well as prepare it for importing it back into Unity later on. This could take a while depending on how good your PC is and how big the game is.

If you encounter any errors while extracting, make sure you left all the settings in the beginning screen on default. Different settings might mess with the exporting a bit.

But, now that we finally have the game files, lets move on to:

Part Two: Importing The Game Back Into Unity

After you've exported the game files and installed the correct unity version of the game, its time to open up Unity and import the game.

Now, don't open the game directly but first open up unity hub and add the game there as a new "project".

The folder name should be the same as the game name but that's not the folder you want to choose. The folder you want is called "Exported Project", select that one and import it into Unity Hub. Unity Hub should have already given it the right Unity version to start with. If it didn't, make sure you installed the correct unity version.

Once you've done that, open up the project. Again, depending on how good your computer is this might take a while.

It'll most likely give you a warning about the project containing compilation errors and it will ask you to open in safe mode. Go ahead and do so.

Once Unity is open, it'll give you a big screen with loads of errors on it. You can mostly ignore all of them and just focus on the bottom part of the screen where it shows you your "assets".

If you right click in this field it should give you an option to open in explorer, go ahead and do so.

You'll now be brought to the project folder. Navigate your way into the Assets folder and then find the scripts folder. Make a backup of this folder somewhere and then delete it from the assets folder. Make sure to also delete the .meta file that Unity creates of the folder. With this still in place Unity is going to get confused. After that click back into Unity and it should start doing something.

After that's done you might be left with just an empty window like this:

This is fine, go ahead and click on the folder labeled "Scenes" below. This should show you all the maps that the game has. I'll just open "FNAFPizza1" here.

And there we go! That's the game imported back into unity, or at least somewhat. To get it "running" we'll still have some extra work to do.

Part Three: Getting The Game Running

This part really depends per game on how difficult it is to actually get the game back into a "running" state. I've put running in quotes because I see running as the game running and not throwing 60 errors upon running the project. This might not mean that you'll be able to play the game but it will mean you'll get to look at the games animations in the editor itself instead of having to export them out of Unity.

Now, to get the game running you have to mess with scripts a bit. Asset Ripper will rip everything that was shipped with the game, sometimes including (broken) unity packages. The first thing you want to do is right click in the assets folder and click "show in explorer". This will open an explorer window in the de-compiled game's directory. Navigate to assets/scripts/ and take a note/screenshot of all the folders that are there. For this game in particular I've taken a screenshot.

Once you've taken a screenshot of this folder, copy everything to another place that isn't the game's directory. Then delete the entire folder. If you then click back into Unity you'll see that unity should start processing the files once again. Once its done that. Check if there are any errors/things in the console. If  you are using a different game, now is the time for yourself to figure out what the game is trying to do and why it isn't running. Usually from looking at the console you get a good understanding of what is going wrong.

As for the game I'm using here today, there are no errors upon deleting everything in the scripts folder and...

0:00
/

The game runs!

Closing Thoughts

De-compiling Unity games is hard. Sometimes you'll get a game that runs perfectly with barely any modifications and other times you'll get game that will crash the Unity editor. It really is a hit or miss with every game.

If you have any questions/improvements feel free to join our discord server at: https://invite.teamneptune.net/

Thanks for reading!
Hax4dayz