From 7a82f70ccdd5f9586435d8eddd6959ea51e3ef26 Mon Sep 17 00:00:00 2001 From: zqy Date: Mon, 5 Jun 2023 19:21:05 +0800 Subject: [PATCH] feat: Show events of the AnimationClip --- Editor/Scripts/Node/AnimationClipPlayableNode.cs | 15 +++++++++++++++ Editor/Scripts/Node/PlayableNode.cs | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Editor/Scripts/Node/AnimationClipPlayableNode.cs b/Editor/Scripts/Node/AnimationClipPlayableNode.cs index 30c2f78..bd05f3b 100644 --- a/Editor/Scripts/Node/AnimationClipPlayableNode.cs +++ b/Editor/Scripts/Node/AnimationClipPlayableNode.cs @@ -158,6 +158,21 @@ protected override void AppendNodeDescription(StringBuilder descBuilder) .Append("AverageAngularSpeed: ").AppendLine(clip.averageAngularSpeed.ToString("F3")) .Append("AverageDuration: ").AppendLine(clip.averageDuration.ToString("F3")) .Append("IsHumanMotion: ").AppendLine(clip.isHumanMotion.ToString()); + + // Event + descBuilder.AppendLine(LINE); + var events = clip.events; + descBuilder.AppendLine( + events.Length == 0 + ? "No Event" + : (events.Length == 1 ? "1 Event:" : $"{events.Length.ToString()} Events:") + ); + for (int i = 0; i < events.Length; i++) + { + var evt = events[i]; + var evtPosition = evt.time / clip.length * 100; + descBuilder.AppendLine($" #{(i + 1).ToString()} {evtPosition.ToString("F2")}% {evt.functionName}"); + } } } } \ No newline at end of file diff --git a/Editor/Scripts/Node/PlayableNode.cs b/Editor/Scripts/Node/PlayableNode.cs index 2628943..07e3d16 100644 --- a/Editor/Scripts/Node/PlayableNode.cs +++ b/Editor/Scripts/Node/PlayableNode.cs @@ -168,7 +168,7 @@ protected override void AppendNodeDescription(StringBuilder descBuilder) descBuilder.AppendLine( inputCount == 0 ? "No Input" - : (inputCount == 1 ? "1 Input:" : $"{inputCount} Inputs:") + : (inputCount == 1 ? "1 Input:" : $"{inputCount.ToString()} Inputs:") ); AppendInputPortDescription(descBuilder); @@ -178,7 +178,7 @@ protected override void AppendNodeDescription(StringBuilder descBuilder) descBuilder.AppendLine( playableOutputCount == 0 ? "No Output" - : (playableOutputCount == 1 ? "1 Output" : $"{playableOutputCount} Outputs") + : (playableOutputCount == 1 ? "1 Output" : $"{playableOutputCount.ToString()} Outputs") ); }