From 5070b21341f0d7a14b85e19768f4affda780e34a Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Wed, 29 May 2013 03:24:44 +0200 Subject: [PATCH] Initialize skeleton on start. --- spine-tk2d/Code/tk2dSpineSkeleton.cs | 18 ++++++++++-------- spine-tk2d/Example/Example.unity | Bin 19464 -> 19460 bytes spine-tk2d/Example/Scripts/tk2dSpineboy.cs | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) 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 5894de0582d3e5d2fcdebaeb73a4271dd9c8d324..71d8354d495e55fd59ec3eff6f5d7e0737c729b8 100644 GIT binary patch delta 554 zcmYk3y-UMT6vc0v27^+m;77HCDb`JB!9j6p3X+sYv~C@o-9&H@ghCNI)URlL6)NcJ zAc~dXrZ@=d*grwUZVp0S{W!OIgurj%-mPGnVy7J?Ps_Ad04=DBJ_ zyIo4DUNba1Q*`gN>7+t*PDEJRIs|LLnDA+-Bd~CQC<*_E+Q3=?Gr=k*b2}DitXQ5R@thuGaG^(FuI#F*{&iVBP0-!Ax9Q!?{7JJ+L~M0lzG@ z57v-u1&npT-;=CBQKAB%3mDdj=F$JiNi^YFV`9~s5;<#lVDq|FIDJ}7KfX7cFD+40 zMa&)&rrqy7TXTxZ2Q)bFyD7iMsf=ilvFKSp!&BA{mi4{?kqQ=*hj*$gr zB?~3pt#6W*?51R4LD@*z`*_}&Bi?#C=lR|Dp7We{VN1zuDL$h32GNjj-DkOb{vMB; z)pYGB(WAL9Wt|=AjCwF(C`36T!cx!@*e%R3yjN-&Ojn7<;j5%pz%pPF_z|g9uzkr! z!B}g2o@8_ItSs28N@?nc`9@7)J#ER)8Xlq@?0>_Yf!%}s4|5I{L9!J3YNal~rokHF zqf(b(yI?l_m%QT&>=n!a`}__SFTMuUH6jzRS4tDvczxx`%-#F(xwY={q`z= 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; }