From 359b25d9d441d286c082e51312012dc2cc37b44c Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Thu, 26 Sep 2013 10:02:17 +0200 Subject: [PATCH] spine-tk2d and spine-unity updated to latest spine-csharp. closes #120 closes #125 --- spine-csharp/src/AnimationState.cs | 2 +- .../Editor/SkeletonDataAssetInspector.cs | 3 +-- spine-tk2d/Assets/Spine/SkeletonAnimation.cs | 14 +++++++------- spine-tk2d/Assets/Spine/SkeletonComponent.cs | 2 +- .../Assets/examples/spineboy/Spineboy.cs | 4 +++- .../Editor/SkeletonDataAssetInspector.cs | 3 +-- spine-unity/Assets/Spine/SkeletonAnimation.cs | 13 +++++++------ spine-unity/Assets/Spine/SkeletonComponent.cs | 2 +- .../Assets/examples/spineboy/Spineboy.cs | 6 +++--- .../spineboy/spineboy SkeletonData.asset | Bin 4244 -> 4264 bytes .../Assets/examples/spineboy/spineboy.unity | Bin 18584 -> 18688 bytes spine-xna/example/src/ExampleGame.cs | 8 ++++---- 12 files changed, 29 insertions(+), 28 deletions(-) diff --git a/spine-csharp/src/AnimationState.cs b/spine-csharp/src/AnimationState.cs index eea852b7b..14cc61135 100644 --- a/spine-csharp/src/AnimationState.cs +++ b/spine-csharp/src/AnimationState.cs @@ -214,7 +214,7 @@ namespace Spine { } /** @return May be null. */ - public TrackEntry getCurrent (int trackIndex) { + public TrackEntry GetCurrent (int trackIndex) { if (trackIndex >= tracks.Count) return null; return tracks[trackIndex]; } diff --git a/spine-tk2d/Assets/Spine/Editor/SkeletonDataAssetInspector.cs b/spine-tk2d/Assets/Spine/Editor/SkeletonDataAssetInspector.cs index 4e9d48093..bb847a700 100644 --- a/spine-tk2d/Assets/Spine/Editor/SkeletonDataAssetInspector.cs +++ b/spine-tk2d/Assets/Spine/Editor/SkeletonDataAssetInspector.cs @@ -30,7 +30,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ - using System; using UnityEditor; using UnityEngine; @@ -101,7 +100,7 @@ public class SkeletonDataAssetInspector : Editor { if (!Application.isPlaying) { if (serializedObject.ApplyModifiedProperties() || - (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed") + (UnityEngine.Event.current.type == EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed") ) { asset.Clear(); } diff --git a/spine-tk2d/Assets/Spine/SkeletonAnimation.cs b/spine-tk2d/Assets/Spine/SkeletonAnimation.cs index 846eab38a..54b5d0e48 100644 --- a/spine-tk2d/Assets/Spine/SkeletonAnimation.cs +++ b/spine-tk2d/Assets/Spine/SkeletonAnimation.cs @@ -30,7 +30,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ - using System; using System.IO; using System.Collections.Generic; @@ -54,15 +53,16 @@ public class SkeletonAnimation : SkeletonComponent { override public void UpdateSkeleton () { if (useAnimationName) { // Keep AnimationState in sync with animationName and loop fields. + TrackEntry entry = state.GetCurrent(0); if (animationName == null || animationName.Length == 0) { - if (state.Animation != null) - state.ClearAnimation(); - } else if (state.Animation == null || animationName != state.Animation.Name) { + if (entry != null && entry.Animation != null) + state.Clear(0); + } else if (entry == null || entry.Animation == null || animationName != entry.Animation.Name) { Spine.Animation animation = skeleton.Data.FindAnimation(animationName); if (animation != null) - state.SetAnimation(animation, loop); - } - state.Loop = loop; + state.SetAnimation(0, animation, loop); + } else if (entry != null) + entry.Loop = loop; } // Apply the animation. diff --git a/spine-tk2d/Assets/Spine/SkeletonComponent.cs b/spine-tk2d/Assets/Spine/SkeletonComponent.cs index a71ef32c0..b4e3a7338 100644 --- a/spine-tk2d/Assets/Spine/SkeletonComponent.cs +++ b/spine-tk2d/Assets/Spine/SkeletonComponent.cs @@ -164,7 +164,7 @@ public class SkeletonComponent : MonoBehaviour { if (regionAttachment == null) continue; - regionAttachment.ComputeVertices(skeleton.X, skeleton.Y, slot.Bone, vertexPositions); + regionAttachment.ComputeWorldVertices(skeleton.X, skeleton.Y, slot.Bone, vertexPositions); vertices[vertexIndex] = new Vector3(vertexPositions[RegionAttachment.X1], vertexPositions[RegionAttachment.Y1], 0); vertices[vertexIndex + 1] = new Vector3(vertexPositions[RegionAttachment.X4], vertexPositions[RegionAttachment.Y4], 0); diff --git a/spine-tk2d/Assets/examples/spineboy/Spineboy.cs b/spine-tk2d/Assets/examples/spineboy/Spineboy.cs index 0dc66aaba..14168e2c7 100644 --- a/spine-tk2d/Assets/examples/spineboy/Spineboy.cs +++ b/spine-tk2d/Assets/examples/spineboy/Spineboy.cs @@ -33,6 +33,7 @@ using UnityEngine; using System.Collections; +using Spine; public class Spineboy : MonoBehaviour { private SkeletonAnimation skeleton; @@ -44,7 +45,8 @@ public class Spineboy : MonoBehaviour { void LateUpdate() { if (skeleton.loop) return; - if (skeleton.state.Animation != null && skeleton.state.Time >= skeleton.state.Animation.Duration - 0.25) { + TrackEntry entry = skeleton.state.GetCurrent(0); + if (entry != null && entry.Time >= entry.Animation.Duration - 0.25) { skeleton.animationName = "walk"; skeleton.loop = true; } diff --git a/spine-unity/Assets/Spine/Editor/SkeletonDataAssetInspector.cs b/spine-unity/Assets/Spine/Editor/SkeletonDataAssetInspector.cs index 184761b21..7f0013a07 100644 --- a/spine-unity/Assets/Spine/Editor/SkeletonDataAssetInspector.cs +++ b/spine-unity/Assets/Spine/Editor/SkeletonDataAssetInspector.cs @@ -30,7 +30,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ - using System; using UnityEditor; using UnityEngine; @@ -97,7 +96,7 @@ public class SkeletonDataAssetInspector : Editor { if (!Application.isPlaying) { if (serializedObject.ApplyModifiedProperties() || - (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed") + (UnityEngine.Event.current.type == EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed") ) { asset.Clear(); } diff --git a/spine-unity/Assets/Spine/SkeletonAnimation.cs b/spine-unity/Assets/Spine/SkeletonAnimation.cs index 3b2c59eeb..54b5d0e48 100644 --- a/spine-unity/Assets/Spine/SkeletonAnimation.cs +++ b/spine-unity/Assets/Spine/SkeletonAnimation.cs @@ -30,7 +30,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ - using System; using System.IO; using System.Collections.Generic; @@ -54,14 +53,16 @@ public class SkeletonAnimation : SkeletonComponent { override public void UpdateSkeleton () { if (useAnimationName) { // Keep AnimationState in sync with animationName and loop fields. + TrackEntry entry = state.GetCurrent(0); if (animationName == null || animationName.Length == 0) { - if (state.Animation != null) state.ClearAnimation(); - } else if (state.Animation == null || animationName != state.Animation.Name) { + if (entry != null && entry.Animation != null) + state.Clear(0); + } else if (entry == null || entry.Animation == null || animationName != entry.Animation.Name) { Spine.Animation animation = skeleton.Data.FindAnimation(animationName); if (animation != null) - state.SetAnimation(animation, loop); - } - state.Loop = loop; + state.SetAnimation(0, animation, loop); + } else if (entry != null) + entry.Loop = loop; } // Apply the animation. diff --git a/spine-unity/Assets/Spine/SkeletonComponent.cs b/spine-unity/Assets/Spine/SkeletonComponent.cs index f9f075f44..ecf3c41be 100644 --- a/spine-unity/Assets/Spine/SkeletonComponent.cs +++ b/spine-unity/Assets/Spine/SkeletonComponent.cs @@ -168,7 +168,7 @@ public class SkeletonComponent : MonoBehaviour { if (regionAttachment == null) continue; - regionAttachment.ComputeVertices(skeleton.X, skeleton.Y, slot.Bone, vertexPositions); + regionAttachment.ComputeWorldVertices(skeleton.X, skeleton.Y, slot.Bone, vertexPositions); vertices[vertexIndex] = new Vector3(vertexPositions[RegionAttachment.X1], vertexPositions[RegionAttachment.Y1], 0); vertices[vertexIndex + 1] = new Vector3(vertexPositions[RegionAttachment.X4], vertexPositions[RegionAttachment.Y4], 0); diff --git a/spine-unity/Assets/examples/spineboy/Spineboy.cs b/spine-unity/Assets/examples/spineboy/Spineboy.cs index 0ad719c25..f3a50d380 100644 --- a/spine-unity/Assets/examples/spineboy/Spineboy.cs +++ b/spine-unity/Assets/examples/spineboy/Spineboy.cs @@ -37,12 +37,12 @@ using System.Collections; public class Spineboy : MonoBehaviour { public void Start () { SkeletonAnimation skeletonAnimation = GetComponent(); - skeletonAnimation.state.SetAnimation("walk", true); + skeletonAnimation.state.SetAnimation(0, "walk", true); } public void OnMouseDown () { SkeletonAnimation skeletonAnimation = GetComponent(); - skeletonAnimation.state.SetAnimation("jump", false); - skeletonAnimation.state.AddAnimation("walk", true); + skeletonAnimation.state.SetAnimation(0, "jump", false); + skeletonAnimation.state.AddAnimation(0, "walk", true, 0); } } diff --git a/spine-unity/Assets/examples/spineboy/spineboy SkeletonData.asset b/spine-unity/Assets/examples/spineboy/spineboy SkeletonData.asset index e41e05273816c4cfbf8d3c469d379a2e22d21d50..1847ae216d8d54893ed4d060aa58bc71b6c09bf1 100644 GIT binary patch delta 83 zcmbQDxI&SGfq}z?fk9x!MvlMij4L*?aYS)2GEYtv5H?|9U|`59%`IRC(l9oNE>FzK ThVemivu4h;JA3Ag9f$@112Pp8 delta 63 zcmZ3XI7N|zfq}z?fk9x(MvlMij8itVaYS)2GEGht5LRGfU|?VY;;ho#0uWuEn3D|> J0|I*x1^}Io3mX6c diff --git a/spine-unity/Assets/examples/spineboy/spineboy.unity b/spine-unity/Assets/examples/spineboy/spineboy.unity index 572a6f9d7881a697ff5f3dbbced6ebec4db0291f..6c6e8161c63c812b485c633d43d461057a877f81 100644 GIT binary patch delta 415 zcmbO+k+ESCqW}Ygb0GtRCj$_00@)Kb3V5+F3T_Oz&pcT`nsu{1M<`=(a$-($X-;BE zs$YIlZemU`10zti0!RxGfY=cI3=E;3c_kJMaOEM1dFiQnB@p$BAay_hQ9rqZQ;|_= z@+wXpM&-#bIg}YyCi8MCGpbHD1d6LocH~lGRNtJ!m2O@i0o3y!2#SF8=FhLZG?*9| zRsh-JP`m{wb^$1+0_2120O74bu^&LO03e$Minjs9JeV069DsaBDBcbf>i~+G0Qvu* zcD(jk5PtwD)(I2?x-|;y;5R_Q0H8?