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

'EndianBinaryReader_Streamable' object has no attribute 'save' #51

Closed
Thuya1980 opened this issue Jun 4, 2021 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@Thuya1980
Copy link

Code

    src = "D:\\ZTA\\MLBG Data\\#MLBGChanger-Python\\restore\\"+b
    src = b"bytes"
    src = io.BytesIO(b"Streamable")
    env = UnityPy.load(src)
    for obj in env.objects:
        if obj.type in ["Texture2D"]:
            # export texture
            data = obj.read()
            if data.name == a:
                # edit texture
                with Image.open(a+".png") as pil_img:
                    data.image = pil_img
                    data.save()
    with open(b, "wb") as f:
        f.write(env.file.save())

Error

    Traceback (most recent call last):
      File "D:\ZTA\MLBG Data\#MLBGChanger-Python\ImageConverter.py", line 78, in <module>
        f.write(env.file.save())
    AttributeError: 'EndianBinaryReader_Streamable' object has no attribute 'save'

Bug
I can't save it.

@Thuya1980 Thuya1980 added the bug Something isn't working label Jun 4, 2021
@K0lb3
Copy link
Owner

K0lb3 commented Jun 8, 2021

This code can't work and doesn't do what you're intended to do.

You pass
src = io.BytesIO(b"Streamable")
to UnityPy.
The object isn't an Unity asset, so UnityPy will just store it as reader.

Since UnityPy got no Unity asset as input, it won't be able to find any objects,
so your loop below won't do anything, in fact, it will just be skipt as env.objects will be empty.

    for obj in env.objects:
        if obj.type in ["Texture2D"]:
            # export texture
            data = obj.read()
            if data.name == a:
                # edit texture
                with Image.open(a+".png") as pil_img:
                    data.image = pil_img
                    data.save()
                    ```
 
 Since you don't change any asset, I'm wondering why you even try to repack/save the "asset".
 Anyway, since you're loading no Unity asset, the save command can't be applied to the only loaded file either.
 

@K0lb3 K0lb3 closed this as completed Jun 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants