HearthSim / UnityPack

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

Error getting type of internal Unity asset "library/unity default resources" #9

Open andburn opened 8 years ago

andburn commented 8 years ago

Calling ObjectInfo.type on the "library/unity default resources" asset raises the error below. This asset occurs in Hearthstone's gameobject0 bundle, causing unityextract to fail.

Traceback (most recent call last):
  File ".\bin\unityextract", line 146, in <module>
    main()
  File ".\bin\unityextract", line 143, in main
    exit(app.run())
  File ".\bin\unityextract", line 56, in run
    self.handle_asset(asset)
  File ".\bin\unityextract", line 82, in handle_asset
    if obj.type not in self.handle_formats:
  File "h:\hearthsim\python-unitypack\unitypack\object.py", line 31, in type
    typename = script.resolve()["m_ClassName"]
  File "h:\hearthsim\python-unitypack\unitypack\object.py", line 174, in resolve
    return self.object.read()
  File "h:\hearthsim\python-unitypack\unitypack\object.py", line 167, in object
    return self.asset.objects[self.path_id]
  File "h:\hearthsim\python-unitypack\unitypack\object.py", line 162, in asset
    ret = ret.resolve()
  File "h:\hearthsim\python-unitypack\unitypack\asset.py", line 173, in resolve
    return self.source.get_asset(self.file_path)
  File "h:\hearthsim\python-unitypack\unitypack\asset.py", line 63, in get_asset
    return self.environment.get_asset_by_filename(path)
  File "h:\hearthsim\python-unitypack\unitypack\environment.py", line 46, in get_asset_by_filename
    raise KeyError("No such asset: %r" % (name))
KeyError: "No such asset: 'library/unity default resources'"
robert-nix commented 8 years ago

Resolve the path via s/^library/Resources/

robert-nix commented 8 years ago

This needs changed https://github.com/HearthSim/UnityPack/blob/master/unitypack/asset.py#L60

and while we're here, need a better way (i.e. type detection) of loading files than explicitly saying asset/assetbundle -- lots of files that are assets don't end in ".assets".

jleclanche commented 8 years ago

UnityPack can't load unity default resources as an asset at all right now - tried last night, failed. @andburn I'd love your help to fix it!

andburn commented 8 years ago

Yeah there seems to be a problem loading files as assets, like resources.assets. I'll have a look into it.

verng95 commented 7 years ago

@andburn I have error library/unity default resources. Have you found any fix? I tried everything out.

Traceback (most recent call last):
  File "D:\Downloads\UnityPack-master\UnityPack-master\bin\unityextract", line 146, in <module>
    main()
  File "D:\Downloads\UnityPack-master\UnityPack-master\bin\unityextract", line 143, in main
    exit(app.run())
  File "D:\Downloads\UnityPack-master\UnityPack-master\bin\unityextract", line 56, in run
    self.handle_asset(asset)
  File "D:\Downloads\UnityPack-master\UnityPack-master\bin\unityextract", line 82, in handle_asset
    if obj.type not in self.handle_formats:
  File "C:\Users\Alexander\AppData\Local\Programs\Python\Python35\lib\site-packages\unitypack\object.py", line 31, in type
    typename = script.resolve()["m_ClassName"]
  File "C:\Users\Alexander\AppData\Local\Programs\Python\Python35\lib\site-packages\unitypack\object.py", line 179, in resolve
    return self.object.read()
  File "C:\Users\Alexander\AppData\Local\Programs\Python\Python35\lib\site-packages\unitypack\object.py", line 172, in object
    return self.asset.objects[self.path_id]
  File "C:\Users\Alexander\AppData\Local\Programs\Python\Python35\lib\site-packages\unitypack\object.py", line 167, in asset
    ret = ret.resolve()
  File "C:\Users\Alexander\AppData\Local\Programs\Python\Python35\lib\site-packages\unitypack\asset.py", line 188, in resolve
    return self.source.get_asset(self.file_path)
  File "C:\Users\Alexander\AppData\Local\Programs\Python\Python35\lib\site-packages\unitypack\asset.py", line 62, in get_asset
    return self.environment.get_asset_by_filename(path)
  File "C:\Users\Alexander\AppData\Local\Programs\Python\Python35\lib\site-packages\unitypack\environment.py", line 46, in get_asset_by_filename
    raise KeyError("No such asset: %r" % (name))
KeyError: "No such asset: 'library/unity default resources'"
andburn commented 7 years ago

@verng Unfortunately not 😞

beheh commented 4 years ago

We've added e1a840bff7e80d6d21d2f7cc033876eabf97fa82 to skip these for now with a warning, so at least bundles containing these files can be loaded. Obviously it would be nicer if we actually fix them, but for now this prevents crashes if you care about different files in the same bundle.