Search Unity

Extract files/assets from a .unitypackage file

Discussion in 'External Tools' started by GregoryFenn, Jun 8, 2019.

  1. GregoryFenn

    GregoryFenn

    Joined:
    Feb 13, 2018
    Posts:
    26
    ,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.
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    2,833
  3. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    729
    I only inspected one file I happened to have on my desktop, so there are probably nuances.

    Code (CSharp):
    1. $  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.