Skip to content

Fix Switch swizzle texture conversion and optimize Texture2DConverter #318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions UnityPy/classes/legacy_patch/Texture2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def _Texture2d_set_image(

if not isinstance(img, Image.Image):
img = Image.open(img)
assert isinstance(img, Image.Image)

platform = self.object_reader.platform if self.object_reader is not None else 0
img_data, tex_format = Texture2DConverter.image_to_texture2d(
Expand Down Expand Up @@ -70,6 +71,7 @@ def _Texture2D_get_image_data(self: Texture2D):
if self.m_StreamData:
from ...helpers.ResourceReader import get_resource_data

assert self.object_reader is not None
return get_resource_data(
self.m_StreamData.path,
self.object_reader.assets_file,
Expand Down
2 changes: 2 additions & 0 deletions UnityPy/classes/legacy_patch/Texture2DArray.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ def _Texture2DArray_get_images(self: Texture2DArray) -> List[Image.Image]:
texture_format = GRAPHICS_TO_TEXTURE_MAP.get(GraphicsFormat(self.m_Format))
if not texture_format:
raise NotImplementedError(f"GraphicsFormat {self.m_Format} not supported yet")
assert self.object_reader is not None

image_data = self.image_data
if image_data is None:
assert self.m_StreamData is not None
image_data = get_resource_data(
self.m_StreamData.path,
self.object_reader.assets_file,
Expand Down
Loading