From 7871801e29fade1d91cedab9650e0699b98ad93e Mon Sep 17 00:00:00 2001 From: NamYCM <34962723+NamYCM@users.noreply.github.com> Date: Fri, 6 Oct 2023 16:45:44 +0000 Subject: [PATCH] Set FPS to animation clip which is autogenerated by skeleton mecanim In some case, the FPS of that animation clip is very important to detect which frame the animation is running at. That's why the we need to sync the FPS of spine animation and generated animation clip --- .../Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs index 316cda832a..ed15a2a87c 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs @@ -130,6 +130,8 @@ public static void GenerateMecanimAnimationClips (SkeletonDataAsset skeletonData } } + SkeletonData skeletonData = skeletonDataAsset.GetSkeletonData(true); + foreach (Animation animations in data.Animations) { string animationName = animations.Name; // Review for unsafe names. Requires runtime implementation too. spineAnimationTable.Add(animationName, animations); @@ -144,6 +146,7 @@ public static void GenerateMecanimAnimationClips (SkeletonDataAsset skeletonData } AnimationClip clip = unityAnimationClipTable[animationName]; + clip.frameRate = skeletonData.Fps; clip.SetCurve("", typeof(GameObject), "dummy", AnimationCurve.Linear(0, 0, animations.Duration, 0)); AnimationClipSettings settings = AnimationUtility.GetAnimationClipSettings(clip); settings.stopTime = animations.Duration;