mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[unity] SkeletonAnimator optional autoreset.
This commit is contained in:
parent
86cfefe30d
commit
da7bb80953
@ -39,6 +39,7 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
public enum MixMode { AlwaysMix, MixNext, SpineStyle }
|
public enum MixMode { AlwaysMix, MixNext, SpineStyle }
|
||||||
public MixMode[] layerMixModes = new MixMode[0];
|
public MixMode[] layerMixModes = new MixMode[0];
|
||||||
|
public bool autoReset = false;
|
||||||
|
|
||||||
#region Bone Callbacks (ISkeletonAnimation)
|
#region Bone Callbacks (ISkeletonAnimation)
|
||||||
protected event UpdateBonesDelegate _UpdateLocal;
|
protected event UpdateBonesDelegate _UpdateLocal;
|
||||||
@ -88,6 +89,39 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
//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).
|
||||||
|
|
||||||
|
// Clear Previous
|
||||||
|
if (autoReset)
|
||||||
|
{
|
||||||
|
for (int layer = 0, n = animator.layerCount; layer < n; layer++) {
|
||||||
|
float layerWeight = animator.GetLayerWeight(layer);
|
||||||
|
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]; float weight = info.weight * layerWeight; if (weight == 0) continue;
|
||||||
|
animationTable[NameHashCode(info.clip)].SetKeyedItemsToSetupPose(skeleton);
|
||||||
|
}
|
||||||
|
if (hasNext) {
|
||||||
|
for (int c = 0; c < nextClipInfo.Length; c++) {
|
||||||
|
var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
|
||||||
|
animationTable[NameHashCode(info.clip)].SetKeyedItemsToSetupPose(skeleton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Apply
|
// Apply
|
||||||
for (int layer = 0, n = animator.layerCount; layer < n; layer++) {
|
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);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user