-
Notifications
You must be signed in to change notification settings - Fork 0
Decompiled Project Repair Cookbook
When you decompile a Unity IL2CPP game using tools like AssetRipper, the resulting project usually opens broken in the Unity Editor. Buttons and text components show as missing scripts, native plugin DLLs fail to load, and importing the full 4–50 GB asset folder takes hours or crashes the editor.
This cookbook contains practical recipes for fixing these decompiler issues using the Python and PowerShell scripts included in the tools/ directory.
AssetRipper assigns one synthetic GUID per assembly (d3e719b59ab71ba3f6b398058c866280) instead of one per script file. Because Unity expects distinct GUIDs for Image, Text, Button, and CanvasScaler, every uGUI component across all your scenes shows as a missing script reference (m_Script: {fileID: ...}).
Run remap-ugui.py against your project's Assets/ directory:
python tools/remap-ugui.py "C:\Path\To\UnityProject\Assets"- Reads
.unityscenes,.prefabfiles, and.assetfiles. - Matches each synthetic
(fileID, synthetic GUID)pair against verified uGUI component signatures. - Rewrites the
m_Scriptpointers to point to Unity's native uGUI package GUIDs. - Backs up modified files once to
<file>.bak. - Is safe to re-run (idempotent).
AssetRipper often writes decompiled managed plugin DLLs with the IMAGE_FILE_DLL header bit cleared and the PE subsystem set to 3 (console) instead of 2 (GUI). This makes Windows DLLs look like standalone executable EXEs. Unity refuses to load them as managed assemblies, causing build errors about missing types.
Run fix-plugin-pe.ps1 in PowerShell targeting your Unity project:
powershell -File tools/fix-plugin-pe.ps1 -ProjectPath "C:\Path\To\UnityProject"- Scans
Assets/recursively for corrupt.dllfiles. - Backs up original DLLs to
UnityProject-plugin-backup/. - Flips the
IMAGE_FILE_DLLcharacteristic bit (0x2000). - Sets the PE subsystem to GUI (2).
- Clears CLI native-entrypoint flags.
- Prints a verification pass confirming Unity will accept the DLLs.
A full decompiled export can be tens of gigabytes. Importing everything into Unity takes hours, fills up disk space, and imports thousands of assets you don't need for the target scenes.
Calculate the exact dependency graph of your target scenes, and copy only the files those scenes actually reference.
Scan your decompiled assets folder to generate a mapping file of guid=path:
Get-ChildItem -Path "C:\DecompiledExport\Assets" -Recurse -Filter *.meta | ForEach-Object {
$g = (Get-Content $_.FullName | Select-String 'guid:\s*([0-9a-f]{32})').Matches.Groups[1].Value
if ($g) { "$g=$($_.FullName -replace '\.meta$','')" }
} | Set-Content "C:\DecompiledExport\guid-map.txt"Run measure-scenes.ps1 to calculate file lists and megabyte totals per scene:
powershell -File tools/measure-scenes.ps1 -Assets "C:\DecompiledExport\Assets" -GuidMap "C:\DecompiledExport\guid-map.txt"Run measure-groups.ps1 to union the scenes you plan to ship (e.g., Menu scenes):
powershell -File tools/measure-groups.ps1 -Assets "C:\DecompiledExport\Assets"Copy the measured group files into your clean, fresh Unity project:
powershell -File tools/import-group.ps1 -Group "A_menu" -Source "C:\DecompiledExport\Assets" -Dest "C:\CleanUnityProject\Assets" -SkipAnimNote: -SkipAnim skips large .anim files to keep the import minimal.
Unity WebGL builds output Brotli-compressed files (.wasm.br, .data.br, .framework.js.br). Running standard python -m http.server fails with browser decompression errors because Python doesn't attach Content-Encoding: br headers or correct MIME types.
Run serve-webgl.py pointing to your WebGL build directory and a port:
python tools/serve-webgl.py "C:\Path\To\WebGLBuild" 8080Open http://127.0.0.1:8080/ in your browser.
- Binds safely to
127.0.0.1. - Sends
Content-Encoding: brfor.brfiles. - Sets correct MIME types (
application/wasm,application/javascript,application/octet-stream).
To check how much compilable C# logic survived decompilation in a project:
python tools/measure-bodies.py "C:\DecompiledExport\Assets\Scripts"python tools/measure-owned.py "C:\DecompiledExport\Assets\Scripts"Both tools will exit with an error on bad directory paths and print clean percentages distinguishing empty/stub methods from live code.