From 8997c1309b1ac0bd64c76fae58e50d1f71665809 Mon Sep 17 00:00:00 2001 From: Snowyegret <79635537+snowyegret23@users.noreply.github.com> Date: Sun, 1 Oct 2023 04:40:38 +0900 Subject: [PATCH 1/4] Update README.md (#202) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 18149b6b..e58e9131 100644 --- a/README.md +++ b/README.md @@ -208,7 +208,7 @@ from PIL import Image for obj in env.objects: if obj.type.name == "Texture2D": # export texture - data = image.read() + data = obj.read() data.image.save(path) # edit texture fp = os.path.join(replace_dir, data.name) From 5d98090a792e36178d23464ed2ae4d768f005252 Mon Sep 17 00:00:00 2001 From: Elioty <Elioty@users.noreply.github.com> Date: Sat, 30 Sep 2023 21:43:36 +0200 Subject: [PATCH 2/4] Update SpriteHelper.py: issue #206 (#207) Fixing the flip transpose operation when extracting a packed sprite image from a texture. --- UnityPy/export/SpriteHelper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UnityPy/export/SpriteHelper.py b/UnityPy/export/SpriteHelper.py index ffcbf98e..9602e9a3 100644 --- a/UnityPy/export/SpriteHelper.py +++ b/UnityPy/export/SpriteHelper.py @@ -66,10 +66,10 @@ def get_image_from_sprite(m_Sprite) -> Image.Image: if settings_raw.packed == 1: rotation = settings_raw.packingRotation if rotation == SpritePackingRotation.kSPRFlipHorizontal: - sprite_image = sprite_image.transpose(Image.FLIP_TOP_BOTTOM) + sprite_image = sprite_image.transpose(Image.FLIP_LEFT_RIGHT) # spriteImage = RotateFlip(RotateFlipType.RotateNoneFlipX) elif rotation == SpritePackingRotation.kSPRFlipVertical: - sprite_image = sprite_image.transpose(Image.FLIP_LEFT_RIGHT) + sprite_image = sprite_image.transpose(Image.FLIP_TOP_BOTTOM) # spriteImage.RotateFlip(RotateFlipType.RotateNoneFlipY) elif rotation == SpritePackingRotation.kSPRRotate180: sprite_image = sprite_image.transpose(Image.ROTATE_180) From 657a0f66cef5f44785c1f92827406eead0e4c6f2 Mon Sep 17 00:00:00 2001 From: Nattsu39 <nattsu39@outlook.com> Date: Sun, 1 Oct 2023 03:44:57 +0800 Subject: [PATCH 3/4] fix: TypeError: 'ABCMeta' object is not subscriptable (#209) collections.abc.Callable cannot be used for type hints when python<3.9 --- UnityPy/tools/extractor.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/UnityPy/tools/extractor.py b/UnityPy/tools/extractor.py index 86f6d98b..4d9ecb6b 100644 --- a/UnityPy/tools/extractor.py +++ b/UnityPy/tools/extractor.py @@ -16,9 +16,8 @@ GameObject, ) from UnityPy.enums.ClassIDType import ClassIDType -from typing import Union, List, Dict +from typing import Union, List, Dict, Callable from pathlib import Path -from collections.abc import Callable def export_obj( From 52ff053be88e00ee5c8aee8c0b78c121087e29e6 Mon Sep 17 00:00:00 2001 From: TWY <24794414+t-wy@users.noreply.github.com> Date: Sun, 1 Oct 2023 04:50:17 +0900 Subject: [PATCH 4/4] Fix ContainerHelper for .container retrieval (#200) This commit is aware of the difference between _container and container_ in old versions of SerializedFile.py for compatibility. --- UnityPy/files/ObjectReader.py | 6 +----- UnityPy/files/SerializedFile.py | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/UnityPy/files/ObjectReader.py b/UnityPy/files/ObjectReader.py index 2ebee31a..a0894340 100644 --- a/UnityPy/files/ObjectReader.py +++ b/UnityPy/files/ObjectReader.py @@ -139,11 +139,7 @@ def set_raw_data(self, data): @property def container(self): - return ( - self.assets_file._container[self.path_id] - if self.path_id in self.assets_file._container - else None - ) + return self.assets_file._container.path_dict.get(self.path_id) @property def Position(self): diff --git a/UnityPy/files/SerializedFile.py b/UnityPy/files/SerializedFile.py index 8f039f47..d26efbba 100644 --- a/UnityPy/files/SerializedFile.py +++ b/UnityPy/files/SerializedFile.py @@ -653,7 +653,7 @@ def __init__(self, container) -> None: self.container = container # support for getitem self.container_dict = {key: value.asset for key, value in container} - self.path_dict = {value.asset.path_id: value.asset for key, value in container} + self.path_dict = {value.asset.path_id: key for key, value in container} def items(self): return ((key, value.asset) for key, value in self.container)