Skip to content

Commit

Permalink
support reading of AnimationEvent from AnimationClip (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmu authored Jan 8, 2024
1 parent 04bf469 commit ae96f2c
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions UnityPy/classes/AnimationClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,21 @@ def FindBinding(self, index):
return None


class AnimationEvent:
def __init__(self, reader):
version = reader.version
self.time = reader.read_float()
self.functionName = reader.read_aligned_string()
self.data = reader.read_aligned_string()
self.objectReferenceParameter = PPtr(reader)
self.floatParameter = reader.read_float()

if version > (3, ):
self.intParameter = reader.read_int()

self.messageOptions = reader.read_int()


class AnimationType(IntEnum):
kLegacy = (1,)
kGeneric = (2,)
Expand Down Expand Up @@ -609,11 +624,12 @@ def __init__(self, reader):
if version >= (4, 3): # 4.3 and up
self.m_ClipBindingConstant = AnimationClipBindingConstant(reader)

if version >= (2018, 3):
self.m_HasGenericRootTransform = reader.read_boolean()
self.m_HasMotionFloatCurves = reader.read_boolean()
reader.align_stream()

# m_HasGenericRootTransform 2018.3
# m_HasMotionFloatCurves 2018.3
# numEvents = reader.read_int()
# self.m_Events = [
# AnimationEvent(reader)
# for _ in range(numEvents)
# ]
numEvents = self.reader.read_int()
self.m_Events = [AnimationEvent(self.reader) for _ in range(numEvents)]
if version >= (2017, ):
reader.align_stream()

0 comments on commit ae96f2c

Please sign in to comment.