Merge pull request #45 from Dgizusse/master

tk2d Support for multiple platform SpriteCollections
This commit is contained in:
Nathan Sweet 2013-05-13 09:06:15 -07:00
commit ae17932d53
3 changed files with 19 additions and 4 deletions

View File

@ -23,8 +23,8 @@ public class tk2dSpineAttachmentLoader : AttachmentLoader {
if(type != AttachmentType.region) throw new Exception("Unknown attachment type: " + type); if(type != AttachmentType.region) throw new Exception("Unknown attachment type: " + type);
tk2dSpriteDefinition attachmentParameters = null; tk2dSpriteDefinition attachmentParameters = null;
for(int i = 0; i < sprites.spriteDefinitions.Length; ++i) { for(int i = 0; i < sprites.inst.spriteDefinitions.Length; ++i) {
tk2dSpriteDefinition def = sprites.spriteDefinitions[i]; tk2dSpriteDefinition def = sprites.inst.spriteDefinitions[i];
if(def.name == name) { if(def.name == name) {
attachmentParameters = def; attachmentParameters = def;
break; break;

View File

@ -10,7 +10,7 @@ using Spine;
[ExecuteInEditMode] [ExecuteInEditMode]
[RequireComponent(typeof(MeshFilter))] [RequireComponent(typeof(MeshFilter))]
[RequireComponent(typeof(MeshRenderer))] [RequireComponent(typeof(MeshRenderer))]
public class tk2dSpineSkeleton : MonoBehaviour { public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionForceBuild {
/* /*
*/ */
@ -137,7 +137,7 @@ public class tk2dSpineSkeleton : MonoBehaviour {
mesh.triangles = triangles; mesh.triangles = triangles;
mesh.RecalculateNormals(); mesh.RecalculateNormals();
renderer.sharedMaterial = skeletonDataAsset.sprites.spriteCollection.materials[0]; renderer.sharedMaterial = skeletonDataAsset.sprites.spriteCollection.inst.materials[0];
} }
/* /*
@ -188,4 +188,15 @@ public class tk2dSpineSkeleton : MonoBehaviour {
state.Update(Time.deltaTime * animationSpeed); state.Update(Time.deltaTime * animationSpeed);
state.Apply(skeleton); state.Apply(skeleton);
} }
public bool UsesSpriteCollection(tk2dSpriteCollectionData spriteCollection) {
return skeletonDataAsset.sprites.spriteCollection == spriteCollection;
}
public void ForceBuild() {
skeletonDataAsset.ForceUpdate();
skeleton = new Skeleton(skeletonDataAsset.GetSkeletonData());
UpdateMesh();
}
} }

View File

@ -68,4 +68,8 @@ public class tk2dSpineSkeletonDataAsset : ScriptableObject {
stateData.SetMix(fromAnimation[i],toAnimation[i],duration[i]); stateData.SetMix(fromAnimation[i],toAnimation[i],duration[i]);
} }
} }
public void ForceUpdate() {
MakeSkeletonAndAnimationData();
}
} }