Skip to content
New issue

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

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

Already on GitHub? # to your account

How to save env file as it's original file type (Compressed) #167

Open
Azg-stdio opened this issue Dec 9, 2022 · 2 comments
Open

How to save env file as it's original file type (Compressed) #167

Azg-stdio opened this issue Dec 9, 2022 · 2 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@Azg-stdio
Copy link

Azg-stdio commented Dec 9, 2022

Code

for root, dirs, files in os.walk(source_folder):
    for file_name in files:
        file_path = os.path.join(root, file_name)
        env = UnityPy.load(file_path)

        # alternative way which keeps the original path
        for path,obj in env.container.items():
            if obj.type.name in ["Texture2D", "Sprite"]:                
                data = obj.read()
                # create dest based on original path
                dest = os.path.join(destination_folder, *path.split("/"))
                # make sure that the dir of that path exists
                os.makedirs(os.path.dirname(dest), exist_ok = True)
                # edit texture
                fp = os.path.join(replace_dir, data.name + '.png')
                pil_img = Image.open(fp)
                data.image = pil_img
                data.image.save(dest)

Error
So this is working right now, it's loading a .bbq file which contains a .png file and other stuff, I'm just changing the .png file and saving, on the destination folder seems like the original path is working and everything, my question is ¿How do you convert it back to being a .bbq file?

To Reproduce
This is the .bbq file I'm trying to edit: https://drive.google.com/file/d/1LA7sKNRrEXUeiHdzYjg8bfWyLSngBnG0/view?usp=sharing

I know it's not really a bug, but didn't found any info about it, thank you for the help and awesome work!

@Azg-stdio Azg-stdio added the bug Something isn't working label Dec 9, 2022
@K0lb3 K0lb3 added help wanted Extra attention is needed question Further information is requested and removed bug Something isn't working labels Dec 10, 2022
@K0lb3
Copy link
Owner

K0lb3 commented Dec 10, 2022

It's described at UnityPy#environment.

So you have to add the following:

        with open(file_path, "wb") as f:
            f.write(env.file.save())

You probably don't want to replace files in place, though,
as patching already once patched files can lead to problems.

@Azg-stdio
Copy link
Author

I see, so my whole idea was wrong from the beggining.

I did try with the assets in the shared.assets bundle files but the library didn't show me anything there, maybe because it's for a game on Unity 2020.3? Does UnityPy work on that version?

Thank you for the help!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants