You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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([]):
Code
(refer to https://github.com/K0lb3/UnityPy?tab=readme-ov-file#example)
test.py
Error
No error code generated, but
print(file_path, env.objects, env.container.items())
always print{path} [] dict_items([])
:output.txt
Bug
None empty output.
To Reproduce
The text was updated successfully, but these errors were encountered: