I recently came across our ball in maze apk file. I was very eager to make some improvements but unfortunatelly somebody must have deleted my Unity project. So I asked my self how to extract an android game made with Unity to get most of the Unity projectfiles back. Essepecially the .assets files as they took the most time to create. This is also a commonly asked question on the internet. Though I could not find a helpful answer.
It’s actually much easier than you’d expect. 😀 In the following article I’ll show you how to do it.
During my research I came across a script that allows you to retrieve mesh data from .apk files. That means you can partly restore your Unity-Project by using an .apk Android file as a basis. According to the developer the extraction scripts also works with Web, PC, iOS, Android, PS3, Xbox 360, OSX and Linux games. As I only have an .apk file, I wasn’t able to test out the compability of other platform types. But as long as the code is structred in a similar way, you should be able to obtain game assets like meshes and textures from PC-games etc as well. One thing to keep in mind is that the location where the assets can be found, may be different. Please read this article for extact information about your platform. Tell me about your experiences in the comments. 😀
It works with any Android game created with Unity.
Information: You could theoretically extract the 3d meshes and textures from well known titles like Templerun or Dead Trigger. But ripping games is (as far as I know) illegal, unless it’s your game or you were given the permission to do so. You only want to do it in cases like mine. Quaintproject assumes no liability!
What you need:
Step1: Downloading software
First you need to download the 3dsMax script from the website above. To activate or install the scripts it’s enough to simply drag the mzp file into the viewport of 3ds Max. The script is basically a set of scripts, as it includes a plugin to convert convert .pvr files (special kind of images, read about that later) to .dds files etc. You have to start 3ds Max in order to make it work.
To have some quick access to the import button click on “Customize”, switch to “Toolbar” and select “Game file import”. Then drag and drop the script to the left toolbar.
Step2: Preparing the .apk for extraction
Next you have to change .apk file ending to .apk.zip the file will still be readable. Dispite that fact a warning might occur.
In the next step you have to extract the zipped folder. You can do this be right clicking on the selcted file and choosing “Extract all” (see screenshot).
The newly created folder will contain many subfolders, which contain your app’s icon, the Android manifest, a bunch of other files which are not human readable and most importantly the .assets files. Sometimes the assets are split into several parts. The script will then automatically merge all the files into one.
Importing the assets to 3ds Max
Start the importing process clicking on the Unity Importer Button. Choose open folder. Then navigate to the folder Data. Finally hit the open button.
The importer script will search the data folder. It displays all the files it was able to find. I’ m mostly interested in the file “Kugellabyrinth” (ball in maze game). Though I choose the option “Import all”. Objects like the camera or the sunlight will be imported as an Empty. We will later get rid of unnecessary objects so there’s no need to click through every single file. It’s a timesaver essepecially when it comes to larger projects. Importing textures worked im my case like a charme. The script will automatically create a folder called “Maps”. Some “.dds files” will be stored within this folder. Dds is an image format. Programms like Blender or Gimp can handle it.
For professional mobile games an image format called .pvr is used. This format can store image information at a reasonable quality but with a very small size. This is the reason why this pvr converter is included in the script libary. It works pretty well but I’ve read that .pvr files couldn’t be converted to a different image format for various reasons. If this happens, use texturepacker to load .pvr image and save it to the image format you need. Of course you can keep the image format to rebuild your app. But if your original textures/ spritesheets don’t involve .pvr files this will be irrelevant.
But back to 3ds Max. As you can see my original textures are applied. Another positive aspect of this method is, that the UV’s of my mesh are still available.
Step 3: Exporting the meshes to Blender
As I only use 3ds Max rudimentary for my ArchViz stuff, so I decided to export my files to Blender. I choose .3ds as it worked best in my case. But all shown steps should be doable in 3ds Max as well. But why not checking out beautiful Blender just for fun? 😀
I use the Blender 3ds. importer to load the meshes. What I get can be seen in the image below:
When using the .3ds importer it can be helpful to get rid of relations, unless they are really needed. Just press Ctrl P and either choose Clear Parent or clear Parent but keep Transformation.
Next we want to delete the empties. These are beeing created for example for the sun light, the camera and other objects that basically have no geometry. Search for “Select by type”, select “Empty” and hit “X” to delete them. One optional step would be to clear the scale. Just search for “Clear Scale”.
For testing I applied all the Textures. The meshes and the textures turned out quite nice. Dispite some colour issues on the obstacle parts. (See screenshot)
All in all I think that the shown method can really be handy, if it comes to restoring lost mesh files including their textures from your Unity games. It’s also a proper method to make mesh-ups of your games, though your project files have been lost. Of course no shaders are included, nor the scripts.
Do you have any questions? – Feel free to post a comment then. 😀