diff --git a/UnityPy/__init__.py b/UnityPy/__init__.py index 7ee0297f..78dc97a3 100644 --- a/UnityPy/__init__.py +++ b/UnityPy/__init__.py @@ -1,4 +1,4 @@ -__version__ = "1.10.5" +__version__ = "1.10.6" from .environment import Environment from .helpers.ArchiveStorageManager import set_assetbundle_decrypt_key diff --git a/UnityPy/classes/Sprite.py b/UnityPy/classes/Sprite.py index 291b2e73..a5a1761b 100644 --- a/UnityPy/classes/Sprite.py +++ b/UnityPy/classes/Sprite.py @@ -50,14 +50,7 @@ def __init__(self, reader): if version >= (2018,): # 2018 and up m_BonesSize = reader.read_int() - # TODO: might occur in earlier 2020 versions - 2020.3.13 reported - if version >= ( - 2020, - 3, - ): - self.m_Bones = [SpriteBone(self.reader) for _ in range(m_BonesSize)] - else: - self.m_Bones = [reader.read_vector2_array() for _ in range(m_BonesSize)] + self.m_Bones = [SpriteBone(self.reader) for _ in range(m_BonesSize)] def save(self, writer: EndianBinaryWriter = None): if writer is None: @@ -96,12 +89,8 @@ def save(self, writer: EndianBinaryWriter = None): if version >= (2018,): # 2018 and up writer.write_int(len(self.m_Bones)) - if version >= (2020, 3): - for bone in self.m_Bones: - bone.save(writer) - else: - for bone in self.m_Bones: - writer.write_vector2_array(bone) + for bone in self.m_Bones: + bone.save(writer, version) self.set_raw_data(writer.bytes) @@ -241,14 +230,28 @@ class SpriteBone: def __init__(self, reader: EndianBinaryReader) -> None: self.name = reader.read_aligned_string() + + if reader.version >= (2021,): + self.guid = reader.read_aligned_string() + self.position = reader.read_vector3() self.rotation = reader.read_quaternion() self.length = reader.read_float() self.parentId = reader.read_int() - def save(self, writer: EndianBinaryWriter): + if reader.version >= (2021,): + self.color = reader.read_color_uint() + + def save(self, writer: EndianBinaryWriter, version): writer.write_aligned_string(self.name) + + if version >= (2021,): + writer.write_aligned_string(self.guid) + writer.write_vector3(self.position) writer.write_quaternion(self.rotation) writer.write_float(self.length) writer.write_int(self.parentId) + + if version >= (2021,): + writer.write_color_uint(self.color) diff --git a/UnityPy/streams/EndianBinaryReader.py b/UnityPy/streams/EndianBinaryReader.py index 0fe7f7db..2435846c 100644 --- a/UnityPy/streams/EndianBinaryReader.py +++ b/UnityPy/streams/EndianBinaryReader.py @@ -178,6 +178,14 @@ def read_rectangle_f(self) -> Rectangle: self.read_float(), self.read_float(), self.read_float(), self.read_float() ) + def read_color_uint(self): + r = self.read_u_byte() + g = self.read_u_byte() + b = self.read_u_byte() + a = self.read_u_byte() + + return Color(r / 255.0, g / 255.0, b / 255.0, a / 255.0) + def read_color4(self) -> Color: return Color( self.read_float(), self.read_float(), self.read_float(), self.read_float() diff --git a/UnityPy/streams/EndianBinaryWriter.py b/UnityPy/streams/EndianBinaryWriter.py index d9861401..6bb92969 100644 --- a/UnityPy/streams/EndianBinaryWriter.py +++ b/UnityPy/streams/EndianBinaryWriter.py @@ -123,6 +123,12 @@ def write_rectangle_f(self, value: Rectangle): self.write_float(value.width) self.write_float(value.height) + def write_color_uint(self, value: Color): + self.write_u_byte(value.R * 255) + self.write_u_byte(value.G * 255) + self.write_u_byte(value.B * 255) + self.write_u_byte(value.A * 255) + def write_color4(self, value: Color): self.write_float(value.R) self.write_float(value.G)