From 63bfcc35bd47b8e165fdb66031e170d19a779c2d Mon Sep 17 00:00:00 2001 From: Rudolf Kolbe Date: Sat, 30 Sep 2023 22:59:02 +0200 Subject: [PATCH] Texture2D - 2022 fix fixes #203 --- UnityPy/classes/Texture2D.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/UnityPy/classes/Texture2D.py b/UnityPy/classes/Texture2D.py index 705aeaba..b9b4a882 100644 --- a/UnityPy/classes/Texture2D.py +++ b/UnityPy/classes/Texture2D.py @@ -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 @@ -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) @@ -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