Skip to content

Commit

Permalink
Texture2D - 2022 fix
Browse files Browse the repository at this point in the history
fixes #203
  • Loading branch information
K0lb3 committed Sep 30, 2023
1 parent 2da63aa commit 63bfcc3
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions UnityPy/classes/Texture2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,23 @@ def __init__(self, reader):
self.m_Width = reader.read_int()
self.m_Height = reader.read_int()
self.m_CompleteImageSize = reader.read_int()
if version >= (2020,): # 2020.1 and up
if version >= (2020, 1): # 2020.1 and up
self.m_MipsStripped = reader.read_int()
self.m_TextureFormat = TextureFormat(reader.read_int())
if version[:2] < (5, 2): # 5.2 down
if version < (5, 2): # 3.4.0 - 5.1.5f1
self.m_MipMap = reader.read_boolean()
else:
else: # 5.2.0f2 and up
self.m_MipCount = reader.read_int()

if version >= (2, 6): # 2.6 and up
self.m_IsReadable = reader.read_boolean() # 2.6 and up
if version >= (2020,): # 2020.1 and up
self.m_IsPreProcessed = reader.read_boolean()
if version >= (2019, 3): # 2019.3 and up
if (2019, 3) <= version < (2022, 2, 0): # 2019.3.0f6 - 2022.2.0a18
self.m_IgnoreMasterTextureLimit = reader.read_boolean()
if version >= (2022, 2, 0): # 2022.2.0f1 and up
self.m_IgnoreMipmapLimit = reader.read_boolean()
self.m_MipmapLimitGroupName = reader.read_aligned_string()
if (3,) <= version[:2] <= (5, 4): # 3.0 - 5.4
self.m_ReadAllowed = reader.read_boolean()
if version >= (2018, 2): # 2018.2 and up
Expand Down Expand Up @@ -188,7 +191,7 @@ def save(self, writer: EndianBinaryWriter = None):
if version >= (2020,): # 2020.1 and up
writer.write_int(self.m_MipsStripped)
writer.write_int(self.m_TextureFormat.value)
if version[:2] < (5, 2): # 5.2 down
if version < (5, 2): # 5.2 down
writer.write_boolean(self.m_MipMap)
else:
writer.write_int(self.m_MipCount)
Expand All @@ -197,8 +200,11 @@ def save(self, writer: EndianBinaryWriter = None):
writer.write_boolean(self.m_IsReadable) # 2.6 and up
if version >= (2020,): # 2020.1 and up
writer.write_boolean(self.m_IsPreProcessed)
if version >= (2019, 3): # 2019.3 and up
if (2019, 3) <= version < (2022, 2, 0): # 2019.3.0f6 - 2022.2.0a18
writer.write_boolean(self.m_IgnoreMasterTextureLimit)
if version >= (2022, 2, 0): # 2022.2.0f1 and up
writer.write_boolean(self.m_IgnoreMipmapLimit)
writer.write_aligned_string(self.m_MipmapLimitGroupName)
if (3,) <= version[:2] <= (5, 4): # 3.0 - 5.4
writer.write_boolean(self.m_ReadAllowed) # 3.0 - 5.4
if version >= (2018, 2): # 2018.2 and up
Expand Down

0 comments on commit 63bfcc3

Please sign in to comment.