forked from K0lb3/UnityPy
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTransform.py
More file actions
35 lines (28 loc) · 1.24 KB
/
Copy pathTransform.py
File metadata and controls
35 lines (28 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from .Component import Component
from .PPtr import PPtr
from ..streams import EndianBinaryWriter
class Transform(Component):
def __init__(self, reader):
super().__init__(reader=reader)
self.m_LocalRotation = reader.read_quaternion()
self.m_LocalPosition = reader.read_vector3()
self.m_LocalScale = reader.read_vector3()
if reader.version[:2] >= (2021, 3): # TODO: check if lower
reader.align_stream()
numChildren = reader.read_int()
self.m_Children = [PPtr(reader) for _ in range(numChildren)]
self.m_Father = PPtr(reader)
def save(self, writer = None, intern_call=False):
if writer is None:
writer = EndianBinaryWriter(endian=self.reader.endian)
super().save(writer)
writer.write_quaternion(self.m_LocalRotation)
writer.write_vector3(self.m_LocalPosition)
writer.write_vector3(self.m_LocalScale)
if self.reader.version[:2] >= (2021, 3): # TODO: check if lower
writer.align_stream()
writer.write_int(len(self.m_Children))
[self.m_Children[i].save(writer) for i in range(len(self.m_Children))]
self.m_Father.save(writer)
if not intern_call:
self.set_raw_data(writer)