Browse Source

[Unity] SkeletonAnimator lastTime calculation added to fix skipped frames

Fenrisul 10 years ago
parent
commit
1f550ce5af
1 changed files with 6 additions and 2 deletions
  1. 6 2
      spine-unity/Assets/spine-unity/SkeletonAnimator.cs

+ 6 - 2
spine-unity/Assets/spine-unity/SkeletonAnimator.cs

@@ -46,6 +46,7 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation {
 
 	Dictionary<string, Spine.Animation> animationTable = new Dictionary<string, Spine.Animation>();
 	Animator animator;
+	float lastTime;
 
 	public override void Reset () {
 		base.Reset();
@@ -62,7 +63,7 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation {
 
 		animator = GetComponent<Animator>();
 
-
+		lastTime = Time.time;
 	}
 
 	void Update () {
@@ -72,12 +73,13 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation {
 		if (layerMixModes.Length != animator.layerCount) {
 			System.Array.Resize<MixMode>(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;
 	}
 }