Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/K0lb3/UnityPy
Browse files Browse the repository at this point in the history
  • Loading branch information
K0lb3 committed Sep 30, 2023
2 parents 910b7c1 + 52ff053 commit 2da63aa
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions UnityPy/export/SpriteHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions UnityPy/files/ObjectReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion UnityPy/files/SerializedFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions UnityPy/tools/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 2da63aa

Please sign in to comment.