HearthSim / UnityPack

Python deserialization library for Unity3D Asset format
https://hearthsim.info/
MIT License
720 stars 153 forks source link

Problem extracting assets from a UnityWeb file #66

Open Rangedz opened 6 years ago

Rangedz commented 6 years ago

UnityPack: 0.8.1

I am having some problems extracting assets from a UnityWeb file. It throws this exception on asset.objects.items():

Traceback (most recent call last):
  File ".\example.py", line 8, in <module>
    for id, object in asset.objects.items():
  File "C:\Users\Rangedz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\unitypack\asset.py", line 83, in objects
    self.load()
  File "C:\Users\Rangedz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\unitypack\asset.py", line 99, in load
    self.metadata_size = buf.read_uint()
  File "C:\Users\Rangedz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\unitypack\utils.py", line 105, in read_uint
    return struct.unpack(self.endian + "I", self.read(4))[0]
struct.error: unpack requires a buffer of 4 bytes

I tried opening it with Unity Assets Bundle Extractor and it seemed to work correctly, so I don't think there is anything wrong with the file. uabe

UnityWeb File: https://drive.google.com/file/d/19N-tjWW1cjIXKbSprvhWQSAyGcdkee-u/view?usp=sharing

Code used:

import unitypack

with open("Event2d.unity3d", "rb") as f:
    bundle = unitypack.load(f)

    for asset in bundle.assets:
        for id, object in asset.objects.items():
            print(id,object.type)