Peeking at Unity Game Source Code with MonoDevelop on Mac OS X
I am occasionally curious to peek at the source code of a Unity game, mainly to see how it is broken into classes. This is easy to do with MonoDevelop.
The solution in this post has some limitations. Comments and the project structure will be lost. Assets can not be viewed. Obfuscated source code will be unintelligible.
Make sure you are not breaking any EULAs before trying this.
Software Versions
Instructions
The easiest way to peek at the source code of a Unity game is to start with an Android APK. Find an Android APK that you know or suspect was made with Unity and unzip it.
Open MonoDevelop and the assets/bin/Data/Managed directory.
If the APK was made with Unity, UnityEngine.dll will be in the directory. The interesting source code tends to be stored in the following files. There may also be some libraries that are used by the game.
- Assembly-CSharp-firstpass.dll
- Assembly-CSharp.dll
- Assembly-UnityScript-firstpass.dll
- Assembly-UnityScript.dll
Drag one or all of the above dll files into MonoDevelop and an Assembly Browser window should open. Select the class you want to view on left hand side of the window. Change Visibility to All members and Language to C# to see a complete decompiled code listing.