mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[unity] SkeletonAnimator.GetAnimation(clip)
This commit is contained in:
parent
0c24e5e2d3
commit
f6f264336a
@ -163,14 +163,14 @@ namespace Spine.Unity {
|
|||||||
for (int c = 0; c < clipInfoCount; c++) {
|
for (int c = 0; c < clipInfoCount; 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)]);
|
previousAnimations.Add(GetAnimation(info.clip));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasNext) {
|
if (hasNext) {
|
||||||
for (int c = 0; c < nextClipInfoCount; c++) {
|
for (int c = 0; c < nextClipInfoCount; 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)]);
|
previousAnimations.Add(GetAnimation(info.clip));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,12 +193,12 @@ 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 < clipInfoCount; c++) {
|
for (int c = 0; c < clipInfoCount; 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, MixPose.Current, MixDirection.In);
|
GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, MixPose.Current, MixDirection.In);
|
||||||
}
|
}
|
||||||
if (hasNext) {
|
if (hasNext) {
|
||||||
for (int c = 0; c < nextClipInfoCount; c++) {
|
for (int c = 0; c < nextClipInfoCount; 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, MixPose.Current, MixDirection.In);
|
GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime , info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, MixPose.Current, MixDirection.In);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // case MixNext || SpineStyle
|
} else { // case MixNext || SpineStyle
|
||||||
@ -206,13 +206,13 @@ namespace Spine.Unity {
|
|||||||
int c = 0;
|
int c = 0;
|
||||||
for (; c < clipInfoCount; c++) {
|
for (; c < clipInfoCount; 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, MixPose.Current, MixDirection.In);
|
GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, 1f, MixPose.Current, MixDirection.In);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Mix the rest
|
// Mix the rest
|
||||||
for (; c < clipInfoCount; c++) {
|
for (; c < clipInfoCount; 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, MixPose.Current, MixDirection.In);
|
GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, MixPose.Current, MixDirection.In);
|
||||||
}
|
}
|
||||||
|
|
||||||
c = 0;
|
c = 0;
|
||||||
@ -221,14 +221,14 @@ namespace Spine.Unity {
|
|||||||
if (mode == MixMode.SpineStyle) {
|
if (mode == MixMode.SpineStyle) {
|
||||||
for (; c < nextClipInfoCount; c++) {
|
for (; c < nextClipInfoCount; 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, MixPose.Current, MixDirection.In);
|
GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime , info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, 1f, MixPose.Current, MixDirection.In);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Mix the rest
|
// Mix the rest
|
||||||
for (; c < nextClipInfoCount; c++) {
|
for (; c < nextClipInfoCount; 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, MixPose.Current, MixDirection.In);
|
GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime , info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, MixPose.Current, MixDirection.In);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -268,25 +268,21 @@ namespace Spine.Unity {
|
|||||||
nextClipInfo = nextClipInfoCache;
|
nextClipInfo = nextClipInfoCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
int NameHashCode (AnimationClip clip) {
|
Spine.Animation GetAnimation (AnimationClip clip) {
|
||||||
int clipNameHashCode;
|
int clipNameHashCode;
|
||||||
if (!clipNameHashCodeTable.TryGetValue(clip, out clipNameHashCode)) {
|
if (!clipNameHashCodeTable.TryGetValue(clip, out clipNameHashCode)) {
|
||||||
clipNameHashCode = clip.name.GetHashCode();
|
clipNameHashCode = clip.name.GetHashCode();
|
||||||
clipNameHashCodeTable.Add(clip, clipNameHashCode);
|
clipNameHashCodeTable.Add(clip, clipNameHashCode);
|
||||||
}
|
}
|
||||||
return clipNameHashCode;
|
Spine.Animation animation;
|
||||||
|
animationTable.TryGetValue(clipNameHashCode, out animation);
|
||||||
|
return animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
class AnimationClipEqualityComparer : IEqualityComparer<AnimationClip> {
|
class AnimationClipEqualityComparer : IEqualityComparer<AnimationClip> {
|
||||||
internal static readonly IEqualityComparer<AnimationClip> Instance = new AnimationClipEqualityComparer();
|
internal static readonly IEqualityComparer<AnimationClip> Instance = new AnimationClipEqualityComparer();
|
||||||
|
public bool Equals (AnimationClip x, AnimationClip y) { return x.GetInstanceID() == y.GetInstanceID(); }
|
||||||
public bool Equals (AnimationClip x, AnimationClip y) {
|
public int GetHashCode (AnimationClip o) { return o.GetInstanceID(); }
|
||||||
return x.GetInstanceID() == y.GetInstanceID();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetHashCode (AnimationClip o) {
|
|
||||||
return o.GetInstanceID();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class IntEqualityComparer : IEqualityComparer<int> {
|
class IntEqualityComparer : IEqualityComparer<int> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user