mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-08 03:36:52 +08:00
Return Attachment after adding from Sprite.
Misc clean up
This commit is contained in:
parent
18bbcfdc6a
commit
fcf90be386
@ -105,28 +105,24 @@ public static class SkeletonExtensions {
|
|||||||
bone.Y = position.y;
|
bone.Y = position.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AttachUnitySprite (this Skeleton skeleton, string slotName, Sprite sprite, string shaderName = "Spine/Skeleton") {
|
public static Attachment AttachUnitySprite (this Skeleton skeleton, string slotName, Sprite sprite, string shaderName = "Spine/Skeleton") {
|
||||||
var loader = new SpriteAttachmentLoader(sprite, Shader.Find(shaderName));
|
var att = sprite.ToRegionAttachment(shaderName);
|
||||||
|
|
||||||
var att = loader.NewRegionAttachment(null, sprite.name, "");
|
|
||||||
skeleton.FindSlot(slotName).Attachment = att;
|
skeleton.FindSlot(slotName).Attachment = att;
|
||||||
|
|
||||||
loader = null;
|
return att;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddUnitySprite (this SkeletonData skeletonData, string slotName, Sprite sprite, string skinName = "", string shaderName = "Spine/Skeleton") {
|
public static Attachment AddUnitySprite (this SkeletonData skeletonData, string slotName, Sprite sprite, string skinName = "", string shaderName = "Spine/Skeleton") {
|
||||||
var loader = new SpriteAttachmentLoader(sprite, Shader.Find(shaderName));
|
var att = sprite.ToRegionAttachment(shaderName);
|
||||||
var att = loader.NewRegionAttachment(null, sprite.name, "");
|
|
||||||
|
|
||||||
var slotIndex = skeletonData.FindSlotIndex(slotName);
|
var slotIndex = skeletonData.FindSlotIndex(slotName);
|
||||||
Skin skin = skeletonData.defaultSkin;
|
Skin skin = skeletonData.defaultSkin;
|
||||||
if (skinName != "")
|
if (skinName != "")
|
||||||
skin = skeletonData.FindSkin(skinName);
|
skin = skeletonData.FindSkin(skinName);
|
||||||
|
|
||||||
|
|
||||||
skin.AddAttachment(slotIndex, att.Name, att);
|
skin.AddAttachment(slotIndex, att.Name, att);
|
||||||
|
|
||||||
loader = null;
|
return att;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RegionAttachment ToRegionAttachment (this Sprite sprite, string shaderName = "Spine/Skeleton") {
|
public static RegionAttachment ToRegionAttachment (this Sprite sprite, string shaderName = "Spine/Skeleton") {
|
||||||
@ -135,5 +131,4 @@ public static class SkeletonExtensions {
|
|||||||
loader = null;
|
loader = null;
|
||||||
return att;
|
return att;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user