Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EOFError: got only 0 bytes out of 4 requested #15

Closed
StarHeartHunt opened this issue Sep 1, 2020 · 2 comments
Closed

EOFError: got only 0 bytes out of 4 requested #15

StarHeartHunt opened this issue Sep 1, 2020 · 2 comments

Comments

@StarHeartHunt
Copy link
Contributor

StarHeartHunt commented Sep 1, 2020

I'm trying to load Materials in the file using UnityPy, but all the Materials cannot be correctly loaded.(UnityPack can load them)

Unity Asset File:Download Here

My Code:

import os
from UnityPy import AssetsManager

def unpack_all_assets(source_folder : str):
    # iterate over all files in source folder
    for root, dirs, files in os.walk(source_folder):
        for file_name in files:
            # generate file_path
            file_path = os.path.join(root, file_name)
            # load that file via AssetsManager
            am = AssetsManager(file_path)

            # iterate over all assets and named objects
            for asset in am.assets.values():
                for obj in asset.objects.values():
                 #   if obj.type == "GameObject" and obj.read().name.startswith("illust"):
                      #  data = obj.read()
                        
                      #  print(data.name, data.read_type_tree())
                        
                    # only process specific object types
                    #if obj.type == "MonoBehaviour" and obj.path_id == 413749536710485738:
                        # parse the object data
                      #  data = obj.read()
                        
                        #print(obj.path_id, data.name, data.type_tree)
                    if obj.type == "Material":
                        print(obj.path_id)
                        data = obj.read()

unpack_all_assets('./')

Traceback:

Traceback (most recent call last):
  File "test.py", line 32, in <module>
    unpack_all_assets('./')
  File "test.py", line 29, in unpack_all_assets
    data = obj.read()
  File "/usr/local/python3/lib/python3.8/site-packages/UnityPy/files/SerializedFile.py", line 670, in read
    return getattr(classes, self.type.name, classes.Object)(self)
  File "/usr/local/python3/lib/python3.8/site-packages/UnityPy/classes/Material.py", line 34, in __init__
    self.disabledShaderPasses = reader.read_string_array()
  File "/usr/local/python3/lib/python3.8/site-packages/UnityPy/streams/EndianBinaryReader.py", line 193, in read_string_array
    return self.read_array(self.read_aligned_string, self.read_int())
  File "/usr/local/python3/lib/python3.8/site-packages/UnityPy/streams/EndianBinaryReader.py", line 175, in read_array
    return [command() for i in range(length)]
  File "/usr/local/python3/lib/python3.8/site-packages/UnityPy/streams/EndianBinaryReader.py", line 175, in <listcomp>
    return [command() for i in range(length)]
  File "/usr/local/python3/lib/python3.8/site-packages/UnityPy/streams/EndianBinaryReader.py", line 131, in read_aligned_string
    length = self.read_int()
  File "/usr/local/python3/lib/python3.8/site-packages/UnityPy/streams/EndianBinaryReader.py", line 85, in read_int
    return struct.unpack(self.endian + "i", self.read(4))[0]
  File "/usr/local/python3/lib/python3.8/site-packages/UnityPy/streams/EndianBinaryReader.py", line 68, in read
    raise EOFError("got only %d bytes out of %d requested" %
EOFError: got only 0 bytes out of 4 requested
@K0lb3
Copy link
Owner

K0lb3 commented Sep 4, 2020

The issue was fixed with the 1.4.6 update.

@StarHeartHunt
Copy link
Contributor Author

Works perfectly right now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants