Extract files/assets from a .unitypackage file

,Hi all,

I have bought dozens of expensive Asset Store packs with things like audio files (usually in .wav format) and 3D models (.fbx or .blend). But I would like to open the downloaded local copy of my purchase and move/edit/hack the assets directly, not just to the extent possible in the Unity Editor after importing. Is this possible??

The assets are saved (in Windows 10) at : “C:\Users\GFenn\AppData\Roaming\Unity\Asset Store-5.x”.

For example, one audio asset of retro sound effects is in the folder: “C:\Users\GFenn\AppData\Roaming\Unity\Asset Store-5.x\Zero Rare\AudioSound FX” and the file is called “Sound FX - Retro Pack.unitypackage”

Some old articles said you can unzip it with 7Zip, by treating the file as a .tar folder, but this produced a garbage file for me that both Windows Media Player and Audacity were unable to read.

Likewise, other .unitypackage files that I have bought and downloaded may contain 2D Sprites and Textures that I would like to expand and play with in tools like GIMP or Krita.

Please can someone tell me how to directly access the assets I bought? I’m sure it’s possible because if you double-click on an asset (e.g. Texture) in your Asset Folder in Unity, then it will open Krita (on my system, could be GIMP or Photoshop or MS Paint for others). So it’s not like the assets are being encrypted or purposely hidden.

I know one “solution” is just to import everything into a dummy Unity game, and then open the Assets folder on my system, but I want eventually to write a batch/cmd script to copy and paste ALL the png/wav/blend/fbx etc files to a new folder on my system, effectively segmenting it away from Unity altogether.

1 Like

You could use a editor script that you can call via commandline that can import the assets for you then you have all the asset you need imported.
you can even extend them to automatically copy them to a different folder after import.

I only inspected one file I happened to have on my desktop, so there are probably nuances.

$  tar zxvf Package.assetpackage

This produced a series of funky-named folders, one for each entry you would see in the Import dialogue. There could be thousands, so take care to unpack these in an empty work area. The names are hex digits, likely encryption hashes since they’re too long to be guids. Maybe they’re encryption hashes OF guids.

In each hash folder, there is a very short file called “pathname”. The contents of this is the full path to the asset file to be imported, e.g., Assets/Shaders/Foobar.shader. Then there is a file called “asset.meta”; if you replace the word “asset” with the contents of the “pathname” you get the Assets/Shaders/Foobar.shader.meta you will need. If this was a folder, that’s all you get, since Unity doesn’t generally do anything else special for folders. For other assets, there will be an “asset” which you rename the same way, the actual contents of the file, Assets/Shaders/Foobar.shader, and also a “preview.png” which is a thumbnail you would see on the Asset Store website.

Someone more motivated could make a very short .CMD, .sh, or .py file which unpacks assetpackages for you. I hope this doesn’t run afoul of Unity rules, but honestly, this file format is made for convenience not security.

2 Likes

Run this from the folder with all the hash folder names. Output will be in /tmp.

#!/usr/bin/env python3
import os
import re
import shutil
for path in os.listdir('.'):
    if not re.match(r'^[a-f0-9]{32}

, path):
continue
src = os.path.join(path, ‘asset’)
if not os.path.exists(src):
continue
print(‘source: ‘, src)
with open(os.path.join(path, ‘pathname’)) as fp:
dst = fp.read()
if dst.endswith(’\x0a\x30\x30’):
dst = dst[0:-3]
dst = os.path.join(‘/tmp’, dst)
print(‘destination: -%s-’ % dst)
dst_dir = os.path.dirname(dst)
print('creating dir: ', dst_dir)
os.makedirs(dst_dir, exist_ok=True)
print(‘copying…’)
shutil.copy(src, dst)

4 Likes

— 8< —

Forget about snooping around in the .unitypackage file and do this:

  • Create a new Unity project in a folder called “Unity Audio Packages”
  • Make sure it’s on a drive with lots of space (don’t waste precious SSD drive space for example)
  • Open the project and now download and import all your audio libraries.
  • Open File Explorer (or Mac equivalent) and go look in /Assets/ folder of your new project and there are all the files! Make copies and edit them as you like.

Same applies to textures and any other file formats.

6 Likes

Python 3 required to run this script. Download here
https://www.python.org/downloads/release

Tutorial to run script

, path):
continue
src = os.path.join(path, ‘asset’)
if not os.path.exists(src):
continue
print(‘source: ‘, src)
with open(os.path.join(path, ‘pathname’)) as fp:
dst = fp.read()
if dst.endswith(’\x0a\x30\x30’):
dst = dst[0:-3]
dst = os.path.join(‘/tmp’, dst)
print(‘destination: -%s-’ % dst)
dst_dir = os.path.dirname(dst)
print('creating dir: ', dst_dir)
os.makedirs(dst_dir, exist_ok=True)
print(‘copying…’)
shutil.copy(src, dst)

[/quote]

Thanks a lot for this script, it helped!, path):
continue
src = os.path.join(path, ‘asset’)
if not os.path.exists(src):
continue
print(‘source: ‘, src)
with open(os.path.join(path, ‘pathname’)) as fp:
dst = fp.read()
if dst.endswith(’\x0a\x30\x30’):
dst = dst[0:-3]
dst = os.path.join(‘/tmp’, dst)
print(‘destination: -%s-’ % dst)
dst_dir = os.path.dirname(dst)
print('creating dir: ', dst_dir)
os.makedirs(dst_dir, exist_ok=True)
print(‘copying…’)
shutil.copy(src, dst)

[/quote]

Thanks a lot for this script, it helped!
1 Like

Found a great tool. GitHub - Cobertos/unitypackage_extractor: Extract a .unitypackage, with or without Python
Go to its release for drag-n-drop style exe.

3 Likes

heres c# code for extracting data

thanks a lot, this worked for me :slight_smile:

The python tool didn’t work for me so I created this
https://github.com/Switch-9867/UnitypackgeExtractor

4 Likes