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

env.objects == [] & env.container.items() == dict_items([]) #234

Open
changchiyou opened this issue May 1, 2024 · 1 comment
Open

env.objects == [] & env.container.items() == dict_items([]) #234

changchiyou opened this issue May 1, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@changchiyou
Copy link

Code

(refer to https://github.com/K0lb3/UnityPy?tab=readme-ov-file#example)

test.py
import os
import UnityPy

def unpack_all_assets(source_folder : str, destination_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 UnityPy.load
            env = UnityPy.load(file_path)
            print(file_path, env.objects, env.container.items())

            # iterate over internal objects
            for obj in env.objects:
                # process specific object types
                print(obj.type.name)
                if obj.type.name in ["Texture2D", "Sprite"]:
                    # parse the object data
                    data = obj.read()

                    # create destination path
                    dest = os.path.join(destination_folder, data.name)

                    # make sure that the extension is correct
                    # you probably only want to do so with images/textures
                    dest, ext = os.path.splitext(dest)
                    dest = dest + ".png"
                    print(dest)

                    img = data.image
                    img.save(dest)

            # alternative way which keeps the original path
            for path,obj in env.container.items():
                print(obj.type.name)
                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)
                    # correct extension
                    dest, ext = os.path.splitext(dest)
                    dest = dest + ".png"
                    print(dest)
                    data.image.save(dest)

unpack_all_assets("./wr", "./images")

Error

No error code generated, but print(file_path, env.objects, env.container.items()) always print {path} [] dict_items([]):

output.txt
./wr/play-services-measurement-sdk.properties [] dict_items([])
./wr/play-services-cloud-messaging.properties [] dict_items([])
./wr/resources.arsc [] dict_items([])
./wr/firebase-auth-interop.properties [] dict_items([])
./wr/firebase-installations.properties [] dict_items([])
./wr/firebase-measurement-connector.properties [] dict_items([])
./wr/.DS_Store [] dict_items([])
./wr/play-services-auth-api-phone.properties [] dict_items([])
./wr/play-services-auth.properties [] dict_items([])
./wr/firebase-encoders-proto.properties [] dict_items([])
./wr/firebase-iid-interop.properties [] dict_items([])
./wr/info.txt [] dict_items([])
./wr/j- [] dict_items([])
./wr/i- [] dict_items([])
./wr/firebase-messaging.properties [] dict_items([])
./wr/AndroidManifest.xml [] dict_items([])
./wr/play-services-measurement-sdk-api.properties [] dict_items([])
./wr/firebase-dynamic-links.properties [] dict_items([])
./wr/play-services-games.properties [] dict_items([])
./wr/firebase-installations-interop.properties [] dict_items([])
./wr/play-services-basement.properties [] dict_items([])
./wr/classes2.dex [] dict_items([])
./wr/play-services-measurement-impl.properties [] dict_items([])
./wr/play-services-measurement.properties [] dict_items([])
./wr/classes.dex [] dict_items([])
./wr/firebase-datatransport.properties [] dict_items([])
./wr/play-services-measurement-base.properties [] dict_items([])
./wr/transport-runtime.properties [] dict_items([])
./wr/b- [] dict_items([])
./wr/play-services-base.properties [] dict_items([])
./wr/transport-backend-cct.properties [] dict_items([])
./wr/a- [] dict_items([])
./wr/firebase-encoders-json.properties [] dict_items([])
./wr/play-services-ads-identifier.properties [] dict_items([])
./wr/play-services-tasks.properties [] dict_items([])
./wr/play-services-auth-base.properties [] dict_items([])
./wr/transport-api.properties [] dict_items([])
./wr/play-services-drive.properties [] dict_items([])
./wr/stamp-cert-sha256 [] dict_items([])
./wr/play-services-stats.properties [] dict_items([])
./wr/firebase-encoders.properties [] dict_items([])
./wr/firebase-analytics.properties [] dict_items([])
./wr/firebase-components.properties [] dict_items([])
./wr/firebase-common.properties [] dict_items([])
./wr/firebase-annotations.properties [] dict_items([])
./wr/play-services-measurement-api.properties [] dict_items([])
./wr/billing.properties [] dict_items([])
./wr/androidsupportmultidexversion.txt [] dict_items([])
./wr/res/.DS_Store [] dict_items([])
./wr/res/mipmap-ldpi-v4/app_icon.png [] dict_items([])
./wr/res/mipmap-ldpi-v4/ic_launcher_foreground.png [] dict_items([])
./wr/res/mipmap-ldpi-v4/app_icon_round.png [] dict_items([])
./wr/res/mipmap-ldpi-v4/ic_launcher_background.png [] dict_items([])
./wr/res/anim/abc_slide_in_bottom.xml [] dict_items([])
./wr/res/anim/btn_radio_to_off_mtrl_dot_group_animation.xml [] dict_items([])
./wr/res/anim/btn_checkbox_to_unchecked_check_path_merged_animation.xml [] dict_items([])
./wr/res/anim/abc_slide_out_top.xml [] dict_items([])
./wr/res/anim/msdk_webview_anim_titlebar_show.xml [] dict_items([])
./wr/res/anim/login_slide_out.xml [] dict_items([])
./wr/res/anim/mobilefre_login_slide_out.xml [] dict_items([])
./wr/res/anim/abc_tooltip_exit.xml [] dict_items([])
./wr/res/anim/btn_checkbox_to_checked_box_inner_merged_animation.xml [] dict_items([])
./wr/res/anim/btn_radio_to_off_mtrl_ring_outer_animation.xml [] dict_items([])
./wr/res/anim/msdk_webview_anim_share_slide_in.xml [] dict_items([])

... 

./wr/assets/bin/Data/sharedassets14.assets [] dict_items([])
./wr/assets/bin/Data/119591e0bb084e848835d237546b3882 [] dict_items([])
./wr/assets/bin/Data/5877a6fd75ebfe24586318bcd94e950d [] dict_items([])
./wr/assets/bin/Data/aa80dc44aa4fe4c43bb9d51d90cf2958 [] dict_items([])
./wr/assets/bin/Data/b266511438fae724f9d3ce6bd26583e8 [] dict_items([])
./wr/assets/bin/Data/sharedassets16.assets [] dict_items([])
./wr/assets/bin/Data/b7f000750830ddb4bbc80065b9314ce9 [] dict_items([])
./wr/assets/bin/Data/1225b8ff614c9cf4e90b8d1f03ac0be4 [] dict_items([])
./wr/assets/bin/Data/1a9ce5640cde5934aae0022f020464a6 [] dict_items([])
./wr/assets/bin/Data/b7748f50c3f837b4b942e07a29e32f00 [] dict_items([])
./wr/assets/bin/Data/a2d01ffde841c1141a5ac0bda01c58fb [] dict_items([])
./wr/assets/bin/Data/936dea238abb0864ab3985a995e16a29 [] dict_items([])
./wr/assets/bin/Data/547dbd5f858c74047ba3f213e4408307 [] dict_items([])
./wr/assets/bin/Data/cd9006dc442cc244e89b3f492384d46a [] dict_items([])
./wr/assets/bin/Data/02c0a84bd64c6f044954d8bde9b46ec8 [] dict_items([])
./wr/assets/bin/Data/sharedassets6.assets [] dict_items([])
./wr/assets/bin/Data/d51bb6f8036fe5d44af68ef9070dd261 [] dict_items([])
./wr/assets/bin/Data/4a11d65ce13d5f542a0ff136cc2f3fba [] dict_items([])
./wr/assets/bin/Data/f952c082cb03451daed3ee968ac6c63e [] dict_items([])
./wr/assets/bin/Data/Managed/Resources/mscorlib.dll-resources.dat [] dict_items([])
./wr/assets/bin/Data/Managed/Resources/I18N.CJK.dll-resources.dat [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/config [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/browscap.ini [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/2.0/web.config [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/2.0/machine.config [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/2.0/DefaultWsdlHelpGenerator.aspx [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/2.0/settings.map [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/2.0/Browsers/Compat.browser [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/4.5/web.config [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/4.5/machine.config [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/4.5/DefaultWsdlHelpGenerator.aspx [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/4.5/settings.map [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/4.5/Browsers/Compat.browser [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/mconfig/config.xml [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/registry/last-btime [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/4.0/web.config [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/4.0/machine.config [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/4.0/DefaultWsdlHelpGenerator.aspx [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/4.0/settings.map [] dict_items([])
./wr/assets/bin/Data/Managed/etc/mono/4.0/Browsers/Compat.browser [] dict_items([])
./wr/assets/bin/Data/Managed/Metadata/global-metadata.dat [] dict_items([])
./wr/assets/bin/Data/Resources/unity_builtin_extra [] dict_items([])
./wr/assets/LZW/down_lzwdict_5_1_1.bin [] dict_items([])
./wr/assets/Audio/Audio.bytes [] dict_items([])
./wr/assets/Region/RegionManifest.json [] dict_items([])
./wr/assets/CloudConfig/default_cloud.json [] dict_items([])

Bug
None empty output.

To Reproduce

  • a copy of the file that causes the problem (already pasted above)
  • following data:
    • Python version: 3.10.13
    • UnityPy version: 1.10.13
@changchiyou changchiyou added the bug Something isn't working label May 1, 2024
@changchiyou
Copy link
Author

changchiyou commented May 1, 2024

output.txt

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

1 participant