Upload files to "/"
Added support for files with more than 1 texture
This commit is contained in:
parent
bf86ede0d2
commit
9b437b610b
19
decode.py
19
decode.py
|
@ -4,11 +4,20 @@ import UnityPy
|
|||
from PIL import Image
|
||||
|
||||
#made by Katboi01
|
||||
def convert(in_path, out_path):
|
||||
env = UnityPy.load(in_path)
|
||||
def convert(in_path, out_path, file_name):
|
||||
env = UnityPy.load(os.path.join(in_path, file_name))
|
||||
|
||||
textures = []
|
||||
for obj in env.objects:
|
||||
if obj.type.name == "Texture2D":
|
||||
textures.append(obj)
|
||||
|
||||
if len(textures) > 1:
|
||||
out_path = os.path.join(out_path, file_name)
|
||||
os.makedirs(out_path, exist_ok=True)
|
||||
|
||||
for idx, obj in enumerate(textures):
|
||||
try:
|
||||
data = obj.read()
|
||||
im : Image = data.image
|
||||
width, height = im.size
|
||||
|
@ -39,7 +48,9 @@ def convert(in_path, out_path):
|
|||
|
||||
result = Image.fromarray(new_image)
|
||||
|
||||
result.save(out_path, format="PNG")
|
||||
result.save(os.path.join(out_path, data.m_Name + ".png"), format="PNG")
|
||||
except Exception as e:
|
||||
print(f"Failed to extract ({idx}/{len(textures)}) from {file_name}", e)
|
||||
|
||||
def main():
|
||||
in_path = "decoder_in"
|
||||
|
@ -54,6 +65,6 @@ def main():
|
|||
for _, _, files in os.walk(in_path):
|
||||
for name in files:
|
||||
print(name)
|
||||
convert(os.path.join(in_path, name), os.path.join(out_path, name))
|
||||
convert(in_path, out_path, name)
|
||||
|
||||
main()
|
Loading…
Reference in New Issue