Skip to content

Commit af02fbd

Browse files
yvsdropK0lb3
andauthored
1.7.23 - Update SpriteHelper type comparisons to use ClassIDType instead of string (K0lb3#74)
* Update SpriteHelper type comparisons to use ClassIDType instead of string After certain changes in the past, doing simple String comparison on the type attribute of objects will no longer work as expected - should be comparing against the ClassIDType enum instead. (or do obj.type.name == "string name") * use ClassIDType.UnknownType instead of "" when failing to get the type Co-authored-by: Rudolf Kolbe <rkolbe96@gmail.com>
1 parent 61ab4fc commit af02fbd

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎UnityPy/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.7.22"
1+
__version__ = "1.7.23"
22

33
from .environment import Environment
44

‎UnityPy/export/SpriteHelper.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from PIL import Image, ImageDraw
44

55
from .Texture2DConverter import get_image_from_texture2d
6+
from ..enums import ClassIDType
67
from ..streams import EndianBinaryReader
78

89

@@ -21,7 +22,7 @@ class SpritePackingMode(IntEnum):
2122

2223

2324
def get_image(sprite, texture, alpha_texture) -> Image:
24-
if alpha_texture and getattr(alpha_texture, "type", "") == "Texture2D":
25+
if alpha_texture and getattr(alpha_texture, "type", ClassIDType.UnknownType) == ClassIDType.Texture2D:
2526
cache_id = (texture.path_id, alpha_texture.path_id)
2627
if cache_id not in sprite.assets_file._cache:
2728
original_image = get_image_from_texture2d(texture.read(), False)
@@ -45,7 +46,7 @@ def get_image_from_sprite(m_Sprite) -> Image:
4546
elif m_Sprite.m_AtlasTags:
4647
# looks like the direct pointer is empty, let's try to find the Atlas via its name
4748
for obj in m_Sprite.assets_file.objects.values():
48-
if obj.type == "SpriteAtlas":
49+
if obj.type == ClassIDType.SpriteAtlas:
4950
atlas = obj.read()
5051
if atlas.name == m_Sprite.m_AtlasTags[0]:
5152
break

0 commit comments

Comments
 (0)