|
@@ -28,7 +28,9 @@
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
*****************************************************************************/
|
|
|
|
|
|
-// Contributed by: Mitch Thompson
|
|
|
+#if UNITY_5_6_OR_NEWER
|
|
|
+#define UNITY_CLIPINFOCACHE
|
|
|
+#endif
|
|
|
|
|
|
using UnityEngine;
|
|
|
using System.Collections.Generic;
|
|
@@ -116,21 +118,29 @@ namespace Spine.Unity {
|
|
|
readonly Dictionary<int, Spine.Animation> animationTable = new Dictionary<int, Spine.Animation>(IntEqualityComparer.Instance);
|
|
|
readonly Dictionary<AnimationClip, int> clipNameHashCodeTable = new Dictionary<AnimationClip, int>(AnimationClipEqualityComparer.Instance);
|
|
|
readonly List<Animation> previousAnimations = new List<Animation>();
|
|
|
- #if UNITY_2017_1_OR_NEWER
|
|
|
+ #if UNITY_CLIPINFOCACHE
|
|
|
readonly List<AnimatorClipInfo> clipInfoCache = new List<AnimatorClipInfo>();
|
|
|
readonly List<AnimatorClipInfo> nextClipInfoCache = new List<AnimatorClipInfo>();
|
|
|
#endif
|
|
|
- Animator animator;
|
|
|
|
|
|
+ Animator animator;
|
|
|
public Animator Animator { get { return this.animator; } }
|
|
|
|
|
|
public void Initialize (Animator animator, SkeletonDataAsset skeletonDataAsset) {
|
|
|
this.animator = animator;
|
|
|
+
|
|
|
+ previousAnimations.Clear();
|
|
|
+
|
|
|
animationTable.Clear();
|
|
|
- clipNameHashCodeTable.Clear();
|
|
|
var data = skeletonDataAsset.GetSkeletonData(true);
|
|
|
foreach (var a in data.Animations)
|
|
|
animationTable.Add(a.Name.GetHashCode(), a);
|
|
|
+
|
|
|
+ clipNameHashCodeTable.Clear();
|
|
|
+ #if UNITY_CLIPINFOCACHE
|
|
|
+ clipInfoCache.Clear();
|
|
|
+ nextClipInfoCache.Clear();
|
|
|
+ #endif
|
|
|
}
|
|
|
|
|
|
public void Apply (Skeleton skeleton) {
|
|
@@ -255,7 +265,7 @@ namespace Spine.Unity {
|
|
|
out int nextClipInfoCount,
|
|
|
out IList<AnimatorClipInfo> clipInfo,
|
|
|
out IList<AnimatorClipInfo> nextClipInfo) {
|
|
|
- #if UNITY_2017_1_OR_NEWER
|
|
|
+ #if UNITY_CLIPINFOCACHE
|
|
|
clipInfoCount = animator.GetCurrentAnimatorClipInfoCount(layer);
|
|
|
nextClipInfoCount = animator.GetNextAnimatorClipInfoCount(layer);
|
|
|
if (clipInfoCache.Capacity < clipInfoCount) clipInfoCache.Capacity = clipInfoCount;
|