Forráskód Böngészése

[unity] Cleanup SkeletonAnimator Update.

pharan 8 éve
szülő
commit
251ca5d03e
1 módosított fájl, 9 hozzáadás és 20 törlés
  1. 9 20
      spine-unity/Assets/spine-unity/SkeletonAnimator.cs

+ 9 - 20
spine-unity/Assets/spine-unity/SkeletonAnimator.cs

@@ -92,29 +92,21 @@ namespace Spine.Unity {
 			//skeleton.Update(Time.deltaTime); // Doesn't actually do anything, currently. (Spine 3.5).
 
 			// Clear Previous
-			if (autoReset)
-			{
+			if (autoReset) {
 				var previousAnimations = this.previousAnimations;
-				for (int i = 0, n = previousAnimations.Count; i < n; i++) {
+				for (int i = 0, n = previousAnimations.Count; i < n; i++)
 					previousAnimations[i].SetKeyedItemsToSetupPose(skeleton);
-				}
-				previousAnimations.Clear();
 
+				previousAnimations.Clear();
 				for (int layer = 0, n = animator.layerCount; layer < n; layer++) {
-					float layerWeight = (layer == 0) ? 1 : animator.GetLayerWeight(layer);
+					float layerWeight = (layer == 0) ? 1 : animator.GetLayerWeight(layer); // Animator.GetLayerWeight always returns 0 on the first layer. Should be interpreted as 1.
 					if (layerWeight <= 0) continue;
 
 					AnimatorStateInfo nextStateInfo = animator.GetNextAnimatorStateInfo(layer);
 
-					#if UNITY_5
 					bool hasNext = nextStateInfo.fullPathHash != 0;
 					AnimatorClipInfo[] clipInfo = animator.GetCurrentAnimatorClipInfo(layer);
 					AnimatorClipInfo[] nextClipInfo = animator.GetNextAnimatorClipInfo(layer);
-					#else
-					bool hasNext = nextStateInfo.nameHash != 0;
-					var clipInfo = animator.GetCurrentAnimationClipState(i);
-					var nextClipInfo = animator.GetNextAnimationClipState(i);
-					#endif
 
 					for (int c = 0; c < clipInfo.Length; c++) {
 						var info = clipInfo[c];
@@ -131,22 +123,19 @@ namespace Spine.Unity {
 				}
 			}
 
-
 			// Apply
 			for (int layer = 0, n = animator.layerCount; layer < n; layer++) {
-				float layerWeight = (layer == 0) ? 1 : animator.GetLayerWeight(layer);
+				float layerWeight = (layer == 0) ? 1 : animator.GetLayerWeight(layer); // Animator.GetLayerWeight always returns 0 on the first layer. Should be interpreted as 1.
 				AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(layer);
 				AnimatorStateInfo nextStateInfo = animator.GetNextAnimatorStateInfo(layer);
 
-				#if UNITY_5
 				bool hasNext = nextStateInfo.fullPathHash != 0;
 				AnimatorClipInfo[] clipInfo = animator.GetCurrentAnimatorClipInfo(layer);
 				AnimatorClipInfo[] nextClipInfo = animator.GetNextAnimatorClipInfo(layer);
-				#else
-				bool hasNext = nextStateInfo.nameHash != 0;
-				var clipInfo = animator.GetCurrentAnimationClipState(i);
-				var nextClipInfo = animator.GetNextAnimationClipState(i);
-				#endif
+//				UNITY 4
+//				bool hasNext = nextStateInfo.nameHash != 0;
+//				var clipInfo = animator.GetCurrentAnimationClipState(i);
+//				var nextClipInfo = animator.GetNextAnimationClipState(i);
 
 				MixMode mode = layerMixModes[layer];
 				if (mode == MixMode.AlwaysMix) {