[unity] Ignore non-Spine dummy AnimationClips.

This commit is contained in:
John 2017-06-10 02:02:41 +08:00 committed by GitHub
parent 9cc2fa6a2b
commit dd0f489eae

View File

@ -90,6 +90,7 @@ namespace Spine.Unity {
System.Array.Resize<MixMode>(ref layerMixModes, animator.layerCount); System.Array.Resize<MixMode>(ref layerMixModes, animator.layerCount);
//skeleton.Update(Time.deltaTime); // Doesn't actually do anything, currently. (Spine 3.5). //skeleton.Update(Time.deltaTime); // Doesn't actually do anything, currently. (Spine 3.5).
Spine.Animation spineAnimation;
// Clear Previous // Clear Previous
if (autoReset) { if (autoReset) {
@ -111,13 +112,15 @@ namespace Spine.Unity {
for (int c = 0; c < clipInfo.Length; c++) { for (int c = 0; c < clipInfo.Length; c++) {
var info = clipInfo[c]; var info = clipInfo[c];
float weight = info.weight * layerWeight; if (weight == 0) continue; float weight = info.weight * layerWeight; if (weight == 0) continue;
previousAnimations.Add(animationTable[NameHashCode(info.clip)]); animationTable.TryGetValue(NameHashCode(info.clip), out spineAnimation);
if (spineAnimation != null) previousAnimations.Add(spineAnimation);
} }
if (hasNext) { if (hasNext) {
for (int c = 0; c < nextClipInfo.Length; c++) { for (int c = 0; c < nextClipInfo.Length; c++) {
var info = nextClipInfo[c]; var info = nextClipInfo[c];
float weight = info.weight * layerWeight; if (weight == 0) continue; float weight = info.weight * layerWeight; if (weight == 0) continue;
previousAnimations.Add(animationTable[NameHashCode(info.clip)]); animationTable.TryGetValue(NameHashCode(info.clip), out spineAnimation);
if (spineAnimation != null) previousAnimations.Add(spineAnimation);
} }
} }
} }
@ -142,12 +145,14 @@ namespace Spine.Unity {
// Always use Mix instead of Applying the first non-zero weighted clip. // Always use Mix instead of Applying the first non-zero weighted clip.
for (int c = 0; c < clipInfo.Length; c++) { for (int c = 0; c < clipInfo.Length; c++) {
var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue; var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed <0), stateInfo.loop, null, weight, false, false); animationTable.TryGetValue(NameHashCode(info.clip), out spineAnimation);
if (spineAnimation != null) spineAnimation.Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed <0), stateInfo.loop, null, weight, false, false);
} }
if (hasNext) { if (hasNext) {
for (int c = 0; c < nextClipInfo.Length; c++) { for (int c = 0; c < nextClipInfo.Length; c++) {
var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue; var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime , info.clip.length,nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, false, false); animationTable.TryGetValue(NameHashCode(info.clip), out spineAnimation);
if (spineAnimation != null) spineAnimation.Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime , info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, false, false);
} }
} }
} else { // case MixNext || SpineStyle } else { // case MixNext || SpineStyle
@ -155,13 +160,15 @@ namespace Spine.Unity {
int c = 0; int c = 0;
for (; c < clipInfo.Length; c++) { for (; c < clipInfo.Length; c++) {
var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue; var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed <0), stateInfo.loop, null, 1f, false, false); animationTable.TryGetValue(NameHashCode(info.clip), out spineAnimation);
if (spineAnimation != null) spineAnimation.Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed <0), stateInfo.loop, null, 1f, false, false);
break; break;
} }
// Mix the rest // Mix the rest
for (; c < clipInfo.Length; c++) { for (; c < clipInfo.Length; c++) {
var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue; var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed <0), stateInfo.loop, null, weight, false, false); animationTable.TryGetValue(NameHashCode(info.clip), out spineAnimation);
if (spineAnimation != null) spineAnimation.Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed <0), stateInfo.loop, null, weight, false, false);
} }
c = 0; c = 0;
@ -170,14 +177,16 @@ namespace Spine.Unity {
if (mode == MixMode.SpineStyle) { if (mode == MixMode.SpineStyle) {
for (; c < nextClipInfo.Length; c++) { for (; c < nextClipInfo.Length; c++) {
var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue; var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime , info.clip.length,nextStateInfo.speed < 0), nextStateInfo.loop, null, 1f, false, false); animationTable.TryGetValue(NameHashCode(info.clip), out spineAnimation);
if (spineAnimation != null) spineAnimation.Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime , info.clip.length,nextStateInfo.speed < 0), nextStateInfo.loop, null, 1f, false, false);
break; break;
} }
} }
// Mix the rest // Mix the rest
for (; c < nextClipInfo.Length; c++) { for (; c < nextClipInfo.Length; c++) {
var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue; var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime , info.clip.length,nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, false, false); animationTable.TryGetValue(NameHashCode(info.clip), out spineAnimation);
if (spineAnimation != null) spineAnimation.Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime , info.clip.length,nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, false, false);
} }
} }
} }