how to decompile unity games

Unveiling Unity: Complete Guide to Decompiling Games

By Joshua Hernandez
AD

Decompiling Unity games can provide valuable insights into game development, allowing you to understand and modify existing codes. However, it's essential to note that decompiling software is a legal grey area, and you should only do so for educational purposes, with games for which you own a legitimate copy. In this article, we'll guide you through the step-by-step process of decompiling Unity games using Unity's own features and third-party tools.

The process involves exporting the game's assets, disassembling the code, and potentially using reverse engineering techniques to understand the game's logic. It's a complex task, but with the right tools and patience, it's achievable. Let's dive into the details.

Preparing Your Game and Environment

Before you begin, ensure you have a clean version of the Unity Hub and a Unity project open. You'll need the Unity Editor, which you can download from the Unity website. It's free for personal use and small business projects. Next, locate the game's executable (.exe if on Windows) you want to decompile in the game's installation folder.

AD
How to quit a game in Unity - VionixStudio
How to quit a game in Unity - VionixStudio
How to Make a Simple Game in Unity 3D
How to Make a Simple Game in Unity 3D
How to Make a Game Like Jetpack Joyride in Unity 2D – Part 1
How to Make a Game Like Jetpack Joyride in Unity 2D – Part 1

For this demonstration, let's use a Unity-developed game. Unity games are packed using a bespoke packaging system, making them more straightforward to decompile than games developed with other engines. Keep in mind that these steps might not work as-is for games not developed with Unity.

Exporting Scene Assets

Unity games often include valuable assets like 3D models, textures, and scripts. You can export these assets using Unity's built-in tools. First, extract the game's .Levels or .Scene files, typically found in the game's installation folder. Then, follow these steps:

Unity Object Pooling: Fix Your FPS the Smart Way
Unity Object Pooling: Fix Your FPS the Smart Way
Optimizing Unity Games Step-by-Step
Optimizing Unity Games Step-by-Step

1. Open Unity Hub and create a new 3D or 2D project, depending on the game's type.
2. In Unity Editor, click on `Assets` > `Import New Asset` and select your extracted .Scene file.
3. Once imported, you'll see the scene in the Project window. Right-click on the scene file and select `Export` > `Selection`.
4. Choose the export settings and click `Export`.

Disassembling the Code

Unity uses a C#-based code system, and its .exe files are IL (Intermediate Language) bytecode. To disassemble this code, you'll need a tool like `jetbrains.dotMemory` for Unity, made by JetBrains. Here's how to use it:

AD

1. Download and install `jetbrains.dotMemory` if you haven't already.
2. Launch the software and select `Attach to Unity` from the start-up window.
3. In Unity Editor, open a scene in your decompiled project.
4. Return to `dotMemory` and click `Attach`.
5. Once attached, you'll see a list of loaded assemblies. Right-click on the game's assembly (usually named after the game) and select `Objects`.
6. You'll now see the game's classes and methods. Right-click on a method and select `Decompile` > `C#`. The decompiled C# code will appear in a new window.

Using Reverse Engineering and Il2Cpp

Some Unity games use the `Il2Cpp` compiler, which converts C# code into native machine code to improve performance. `Il2Cpp` is proprietary, and decompiling games that use it can be challenging. However, a popular tool called `Il2Cpp Reverse Engineering` can help:

1. Download and extract the tool's repository from GitHub.
2. Extract the game's .exe file and place it in the tool's folder.
3. Run `ReverseIL2CPP.bat` (Windows) or `ReverseIL2CPP.sh` (Linux/macOS).
4. A decompiled project will be created in the `DecompilationOutput` folder.

AD

Remember, decompiling games can be complex and time-consuming. It's a skill that improves with practice, and each game's .exe can present unique challenges. Always ensure you're decompiling legally and responsibly, and only for educational purposes.

Now that you've completed the decompilation process, it's time to analyze the decompiled code. You might want to compare it with your original game code, check the game's logic, or even port the game to a different engine. Keep exploring and happy decompiling!

AD