This repository has been archived on 2024-07-21. You can view files and clone it, but cannot push or open issues or pull requests.
Public_Assets/t1.py

35 lines
1.2 KiB
Python
Raw Normal View History

2023-01-30 20:34:21 +08:00
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)
# iterate over internal objects
for obj in env.objects:
# process specific object types
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"
img = data.image
img.save(dest)
if __name__ == "__main__":
unpack_all_assets("F:\\data", "F:\\data_out")