diff --git a/spine-tk2d/Code/tk2dSpineSkeleton.cs b/spine-tk2d/Code/tk2dSpineSkeleton.cs index 4f2fa853a..a9b383920 100644 --- a/spine-tk2d/Code/tk2dSpineSkeleton.cs +++ b/spine-tk2d/Code/tk2dSpineSkeleton.cs @@ -29,9 +29,12 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor vertexPositions = new float[8]; } + void Start () { + Initialize(); + } + void Update () { - SkeletonData skeletonData = (skeletonDataAsset != null) ? skeletonDataAsset.GetSkeletonData() : null; - + SkeletonData skeletonData = skeletonDataAsset == null ? null : skeletonDataAsset.GetSkeletonData(); if (skeletonData == null) { Clear(); return; @@ -46,6 +49,7 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor } private void Clear() { + Debug.Log("clear?!"); GetComponent().mesh = null; DestroyImmediate(mesh); mesh = null; @@ -161,14 +165,12 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor private void UpdateAnimation() { // Check if we need to stop current animation - if(state.Animation != null && animationName == null) { + if (state.Animation != null && animationName == null) { state.ClearAnimation(); - } - - // Check for different animation name or animation end - else if(state.Animation == null || animationName != state.Animation.Name) { + } else if (state.Animation == null || animationName != state.Animation.Name) { + // Check for different animation name or animation end Spine.Animation animation = skeleton.Data.FindAnimation(animationName); - if(animation != null) state.SetAnimation(animation,loop); + if (animation != null) state.SetAnimation(animation,loop); } state.Loop = loop; diff --git a/spine-tk2d/Example/Example.unity b/spine-tk2d/Example/Example.unity index 5894de058..71d8354d4 100644 Binary files a/spine-tk2d/Example/Example.unity and b/spine-tk2d/Example/Example.unity differ diff --git a/spine-tk2d/Example/Scripts/tk2dSpineboy.cs b/spine-tk2d/Example/Scripts/tk2dSpineboy.cs index a9461d03c..ce53301af 100644 --- a/spine-tk2d/Example/Scripts/tk2dSpineboy.cs +++ b/spine-tk2d/Example/Scripts/tk2dSpineboy.cs @@ -18,9 +18,9 @@ public class tk2dSpineboy : MonoBehaviour { /* */ void Update() { - if(skeleton.loop) return; + if (skeleton.loop) return; - if(skeleton.state.Time >= skeleton.state.Animation.Duration - 0.25) { + if (skeleton.state.Animation != null && skeleton.state.Time >= skeleton.state.Animation.Duration - 0.25) { skeleton.animationName = "walk"; skeleton.loop = true; } diff --git a/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs b/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs index 385b3f576..8b10f24a6 100644 --- a/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs +++ b/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs @@ -128,7 +128,7 @@ public class SkeletonComponent : MonoBehaviour { if (attachment is RegionAttachment) { RegionAttachment regionAttachment = (RegionAttachment)attachment; - regionAttachment.ComputeVertices(slot.Bone, vertexPositions); + regionAttachment.ComputeVertices(skeleton.X, skeleton.Y, slot.Bone, vertexPositions); int vertexIndex = quadIndex * 4; vertices[vertexIndex] = new Vector3(vertexPositions[RegionAttachment.X1], vertexPositions[RegionAttachment.Y1], 0); vertices[vertexIndex + 1] = new Vector3(vertexPositions[RegionAttachment.X4], vertexPositions[RegionAttachment.Y4], 0);