mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
Merge pull request #45 from Dgizusse/master
tk2d Support for multiple platform SpriteCollections
This commit is contained in:
commit
ae17932d53
@ -23,8 +23,8 @@ public class tk2dSpineAttachmentLoader : AttachmentLoader {
|
||||
if(type != AttachmentType.region) throw new Exception("Unknown attachment type: " + type);
|
||||
|
||||
tk2dSpriteDefinition attachmentParameters = null;
|
||||
for(int i = 0; i < sprites.spriteDefinitions.Length; ++i) {
|
||||
tk2dSpriteDefinition def = sprites.spriteDefinitions[i];
|
||||
for(int i = 0; i < sprites.inst.spriteDefinitions.Length; ++i) {
|
||||
tk2dSpriteDefinition def = sprites.inst.spriteDefinitions[i];
|
||||
if(def.name == name) {
|
||||
attachmentParameters = def;
|
||||
break;
|
||||
|
||||
@ -10,7 +10,7 @@ using Spine;
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(MeshFilter))]
|
||||
[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.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.Apply(skeleton);
|
||||
}
|
||||
|
||||
public bool UsesSpriteCollection(tk2dSpriteCollectionData spriteCollection) {
|
||||
return skeletonDataAsset.sprites.spriteCollection == spriteCollection;
|
||||
}
|
||||
|
||||
public void ForceBuild() {
|
||||
skeletonDataAsset.ForceUpdate();
|
||||
skeleton = new Skeleton(skeletonDataAsset.GetSkeletonData());
|
||||
|
||||
UpdateMesh();
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,4 +68,8 @@ public class tk2dSpineSkeletonDataAsset : ScriptableObject {
|
||||
stateData.SetMix(fromAnimation[i],toAnimation[i],duration[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void ForceUpdate() {
|
||||
MakeSkeletonAndAnimationData();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user