spine-tk2d and spine-unity updated to latest spine-csharp.

closes #120
closes #125
This commit is contained in:
NathanSweet 2013-09-26 10:02:17 +02:00
parent 782bde21a0
commit 359b25d9d4
12 changed files with 29 additions and 28 deletions

View File

@ -214,7 +214,7 @@ namespace Spine {
} }
/** @return May be null. */ /** @return May be null. */
public TrackEntry getCurrent (int trackIndex) { public TrackEntry GetCurrent (int trackIndex) {
if (trackIndex >= tracks.Count) return null; if (trackIndex >= tracks.Count) return null;
return tracks[trackIndex]; return tracks[trackIndex];
} }

View File

@ -30,7 +30,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/ *****************************************************************************/
using System; using System;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
@ -101,7 +100,7 @@ public class SkeletonDataAssetInspector : Editor {
if (!Application.isPlaying) { if (!Application.isPlaying) {
if (serializedObject.ApplyModifiedProperties() || 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(); asset.Clear();
} }

View File

@ -30,7 +30,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/ *****************************************************************************/
using System; using System;
using System.IO; using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
@ -54,15 +53,16 @@ public class SkeletonAnimation : SkeletonComponent {
override public void UpdateSkeleton () { override public void UpdateSkeleton () {
if (useAnimationName) { if (useAnimationName) {
// Keep AnimationState in sync with animationName and loop fields. // Keep AnimationState in sync with animationName and loop fields.
TrackEntry entry = state.GetCurrent(0);
if (animationName == null || animationName.Length == 0) { if (animationName == null || animationName.Length == 0) {
if (state.Animation != null) if (entry != null && entry.Animation != null)
state.ClearAnimation(); state.Clear(0);
} else if (state.Animation == null || animationName != state.Animation.Name) { } else if (entry == null || entry.Animation == null || animationName != entry.Animation.Name) {
Spine.Animation animation = skeleton.Data.FindAnimation(animationName); Spine.Animation animation = skeleton.Data.FindAnimation(animationName);
if (animation != null) if (animation != null)
state.SetAnimation(animation, loop); state.SetAnimation(0, animation, loop);
} } else if (entry != null)
state.Loop = loop; entry.Loop = loop;
} }
// Apply the animation. // Apply the animation.

View File

@ -164,7 +164,7 @@ public class SkeletonComponent : MonoBehaviour {
if (regionAttachment == null) if (regionAttachment == null)
continue; 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] = new Vector3(vertexPositions[RegionAttachment.X1], vertexPositions[RegionAttachment.Y1], 0);
vertices[vertexIndex + 1] = new Vector3(vertexPositions[RegionAttachment.X4], vertexPositions[RegionAttachment.Y4], 0); vertices[vertexIndex + 1] = new Vector3(vertexPositions[RegionAttachment.X4], vertexPositions[RegionAttachment.Y4], 0);

View File

@ -33,6 +33,7 @@
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using Spine;
public class Spineboy : MonoBehaviour { public class Spineboy : MonoBehaviour {
private SkeletonAnimation skeleton; private SkeletonAnimation skeleton;
@ -44,7 +45,8 @@ public class Spineboy : MonoBehaviour {
void LateUpdate() { void LateUpdate() {
if (skeleton.loop) return; 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.animationName = "walk";
skeleton.loop = true; skeleton.loop = true;
} }

View File

@ -30,7 +30,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/ *****************************************************************************/
using System; using System;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
@ -97,7 +96,7 @@ public class SkeletonDataAssetInspector : Editor {
if (!Application.isPlaying) { if (!Application.isPlaying) {
if (serializedObject.ApplyModifiedProperties() || 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(); asset.Clear();
} }

View File

@ -30,7 +30,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/ *****************************************************************************/
using System; using System;
using System.IO; using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
@ -54,14 +53,16 @@ public class SkeletonAnimation : SkeletonComponent {
override public void UpdateSkeleton () { override public void UpdateSkeleton () {
if (useAnimationName) { if (useAnimationName) {
// Keep AnimationState in sync with animationName and loop fields. // Keep AnimationState in sync with animationName and loop fields.
TrackEntry entry = state.GetCurrent(0);
if (animationName == null || animationName.Length == 0) { if (animationName == null || animationName.Length == 0) {
if (state.Animation != null) state.ClearAnimation(); if (entry != null && entry.Animation != null)
} else if (state.Animation == null || animationName != state.Animation.Name) { state.Clear(0);
} else if (entry == null || entry.Animation == null || animationName != entry.Animation.Name) {
Spine.Animation animation = skeleton.Data.FindAnimation(animationName); Spine.Animation animation = skeleton.Data.FindAnimation(animationName);
if (animation != null) if (animation != null)
state.SetAnimation(animation, loop); state.SetAnimation(0, animation, loop);
} } else if (entry != null)
state.Loop = loop; entry.Loop = loop;
} }
// Apply the animation. // Apply the animation.

View File

@ -168,7 +168,7 @@ public class SkeletonComponent : MonoBehaviour {
if (regionAttachment == null) if (regionAttachment == null)
continue; 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] = new Vector3(vertexPositions[RegionAttachment.X1], vertexPositions[RegionAttachment.Y1], 0);
vertices[vertexIndex + 1] = new Vector3(vertexPositions[RegionAttachment.X4], vertexPositions[RegionAttachment.Y4], 0); vertices[vertexIndex + 1] = new Vector3(vertexPositions[RegionAttachment.X4], vertexPositions[RegionAttachment.Y4], 0);

View File

@ -37,12 +37,12 @@ using System.Collections;
public class Spineboy : MonoBehaviour { public class Spineboy : MonoBehaviour {
public void Start () { public void Start () {
SkeletonAnimation skeletonAnimation = GetComponent<SkeletonAnimation>(); SkeletonAnimation skeletonAnimation = GetComponent<SkeletonAnimation>();
skeletonAnimation.state.SetAnimation("walk", true); skeletonAnimation.state.SetAnimation(0, "walk", true);
} }
public void OnMouseDown () { public void OnMouseDown () {
SkeletonAnimation skeletonAnimation = GetComponent<SkeletonAnimation>(); SkeletonAnimation skeletonAnimation = GetComponent<SkeletonAnimation>();
skeletonAnimation.state.SetAnimation("jump", false); skeletonAnimation.state.SetAnimation(0, "jump", false);
skeletonAnimation.state.AddAnimation("walk", true); skeletonAnimation.state.AddAnimation(0, "walk", true, 0);
} }
} }

View File

@ -150,19 +150,19 @@ namespace Spine {
} }
public void Start (object sender, StartEndArgs e) { public void Start (object sender, StartEndArgs e) {
Console.WriteLine(e.TrackIndex + " " + state.getCurrent(e.TrackIndex) + ": start"); Console.WriteLine(e.TrackIndex + " " + state.GetCurrent(e.TrackIndex) + ": start");
} }
public void End (object sender, StartEndArgs e) { public void End (object sender, StartEndArgs e) {
Console.WriteLine(e.TrackIndex + " " + state.getCurrent(e.TrackIndex) + ": end"); Console.WriteLine(e.TrackIndex + " " + state.GetCurrent(e.TrackIndex) + ": end");
} }
public void Complete (object sender, CompleteArgs e) { public void Complete (object sender, CompleteArgs e) {
Console.WriteLine(e.TrackIndex + " " + state.getCurrent(e.TrackIndex) + ": complete " + e.LoopCount); Console.WriteLine(e.TrackIndex + " " + state.GetCurrent(e.TrackIndex) + ": complete " + e.LoopCount);
} }
public void Event (object sender, EventTriggeredArgs e) { public void Event (object sender, EventTriggeredArgs e) {
Console.WriteLine(e.TrackIndex + " " + state.getCurrent(e.TrackIndex) + ": event " + e.Event); Console.WriteLine(e.TrackIndex + " " + state.GetCurrent(e.TrackIndex) + ": event " + e.Event);
} }
} }
} }