From 1f550ce5afd6106f0c1ca0bcf40da6d8ad6c4f27 Mon Sep 17 00:00:00 2001 From: Fenrisul Date: Thu, 4 Jun 2015 11:18:52 -0700 Subject: [PATCH] [Unity] SkeletonAnimator lastTime calculation added to fix skipped frames --- spine-unity/Assets/spine-unity/SkeletonAnimator.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spine-unity/Assets/spine-unity/SkeletonAnimator.cs b/spine-unity/Assets/spine-unity/SkeletonAnimator.cs index 4daeda41e..e9abf894a 100644 --- a/spine-unity/Assets/spine-unity/SkeletonAnimator.cs +++ b/spine-unity/Assets/spine-unity/SkeletonAnimator.cs @@ -46,6 +46,7 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation { Dictionary animationTable = new Dictionary(); Animator animator; + float lastTime; public override void Reset () { base.Reset(); @@ -62,7 +63,7 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation { animator = GetComponent(); - + lastTime = Time.time; } void Update () { @@ -72,12 +73,13 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation { if (layerMixModes.Length != animator.layerCount) { System.Array.Resize(ref layerMixModes, animator.layerCount); } + float deltaTime = Time.time - lastTime; skeleton.Update(Time.deltaTime); //apply int layerCount = animator.layerCount; - float deltaTime = Time.deltaTime; + for (int i = 0; i < layerCount; i++) { float layerWeight = animator.GetLayerWeight(i); @@ -183,5 +185,7 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation { if (_UpdateComplete != null) { _UpdateComplete(this); } + + lastTime = Time.time; } } \ No newline at end of file