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