K0lb3 / UnityPy

UnityPy is python module that makes it possible to extract/unpack and edit Unity assets
MIT License
771 stars 114 forks source link

Intermittent error when extracting files from the game Autonauts #192

Open sparr opened 1 year ago

sparr commented 1 year ago

Code The code in question lives at https://github.com/sparr/vgm-extractor/tree/548abc7d017edfad06dd55170c9a0c7269c56dff but I have not reduced this to a test case yet. I will try to do so when I have a chance.

It is effectively attempting to do this:

extract_assets(
    "Autonauts_Data/sharedassets0.assets",
    ".",
    use_container = False,
    append_path_id = False,
    asset_filter = asset_filter,
)

This problem also occurs with Slipways_Data/resources.assets from the game Slipways.

Error

  File "/home/sparr/.local/share/virtualenvs/vgm-extractor-1oHW3IDG/lib/python3.11/site-packages/UnityPy/tools/extractor.py", line 138, in extract_assets
    export_obj(
  File "/home/sparr/.local/share/virtualenvs/vgm-extractor-1oHW3IDG/lib/python3.11/site-packages/UnityPy/tools/extractor.py", line 69, in export_obj
    return export_func(obj, fp, extension)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sparr/.local/share/virtualenvs/vgm-extractor-1oHW3IDG/lib/python3.11/site-packages/UnityPy/tools/extractor.py", line 234, in exportAudioClip
    if len(samples) == 0:
       ^^^^^^^^^^^^
TypeError: object of type 'NoneType' has no len()

Bug The samples here is None about half the time when I try to extract files from this game, and there is no error the other half. There may be a race condition of some sort?

To Reproduce

  1. Use python 3.11.3 and UnityPy 1.10.1 plus #191
  2. Clone the vgm-extractor repo linked above
  3. Install the game Autonauts via Steam
  4. src/vgm-extractor.py -vvvv -o tmp --rescan --overwrite --steamlibrarypath ~/.steam/steam "Autonauts"