mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
[unity] SkeletonAnimator deferred autoReset.
This commit is contained in:
parent
0a423c3757
commit
0279c3a391
@ -37,17 +37,19 @@ namespace Spine.Unity.Editor {
|
||||
[CanEditMultipleObjects]
|
||||
public class SkeletonAnimatorInspector : SkeletonRendererInspector {
|
||||
protected SerializedProperty layerMixModes;
|
||||
protected SerializedProperty autoReset;
|
||||
|
||||
protected override void OnEnable () {
|
||||
base.OnEnable();
|
||||
autoReset = serializedObject.FindProperty("autoReset");
|
||||
layerMixModes = serializedObject.FindProperty("layerMixModes");
|
||||
}
|
||||
|
||||
protected override void DrawInspectorGUI (bool multi) {
|
||||
base.DrawInspectorGUI(multi);
|
||||
EditorGUILayout.PropertyField(autoReset);
|
||||
EditorGUILayout.PropertyField(layerMixModes, true);
|
||||
|
||||
if (!TargetIsValid) return;
|
||||
|
||||
if (!isInspectingPrefab)
|
||||
DrawSkeletonUtilityButton(multi);
|
||||
}
|
||||
|
||||
@ -39,7 +39,9 @@ namespace Spine.Unity {
|
||||
|
||||
public enum MixMode { AlwaysMix, MixNext, SpineStyle }
|
||||
public MixMode[] layerMixModes = new MixMode[0];
|
||||
|
||||
public bool autoReset = false;
|
||||
List<Animation> previousAnimations = new List<Animation>();
|
||||
|
||||
#region Bone Callbacks (ISkeletonAnimation)
|
||||
protected event UpdateBonesDelegate _UpdateLocal;
|
||||
@ -92,6 +94,12 @@ namespace Spine.Unity {
|
||||
// Clear Previous
|
||||
if (autoReset)
|
||||
{
|
||||
var previousAnimations = this.previousAnimations;
|
||||
for (int i = 0, n = previousAnimations.Count; i < n; i++) {
|
||||
previousAnimations[i].SetKeyedItemsToSetupPose(skeleton);
|
||||
}
|
||||
previousAnimations.Clear();
|
||||
|
||||
for (int layer = 0, n = animator.layerCount; layer < n; layer++) {
|
||||
float layerWeight = animator.GetLayerWeight(layer);
|
||||
if (layerWeight <= 0) continue;
|
||||
@ -109,13 +117,15 @@ namespace Spine.Unity {
|
||||
#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);
|
||||
var info = clipInfo[c];
|
||||
float weight = info.weight * layerWeight; if (weight == 0) continue;
|
||||
previousAnimations.Add(animationTable[NameHashCode(info.clip)]);
|
||||
}
|
||||
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);
|
||||
var info = nextClipInfo[c];
|
||||
float weight = info.weight * layerWeight; if (weight == 0) continue;
|
||||
previousAnimations.Add(animationTable[NameHashCode(info.clip)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user