K0lb3 / UnityPy

UnityPy is python module that makes it possible to extract/unpack and edit Unity assets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use unitypy export files by the scene hierarchy?

Mi0KINM opened this issue · comments

like this
image
Because the file name and container path are same.
image
So when I export the spine files with unitypy ,they would be overwritten.Then, I can only get one file.
image
So,could it export files by the scene hierarchy?
Or any other method could make png, atlas, and skel match is ok.
code:

import os
import UnityPy
from PIL import Image
path = os.path.join(os.path.dirname(os.path.abspath('__file__')), "input")
for f in os.listdir(path):
    env = UnityPy.load(os.path.join(path, f))
    for obj in env.objects:
        if obj.type.name == "Texture2D":
            png = obj.read()
            png.image.save(png.name + '.png')
            png.image = png.image.transpose(Image.ROTATE_90)
            png.save()
        if obj.type.name == "TextAsset":
            a = obj.read()
            with open(a.name, "wb") as f:
                f.write(bytes(a.script))

Sample file:https://drive.google.com/file/d/14R9pFOh1UizFxAaV6Sx5Kt65nyPlEruc/view?usp=sharing