Sorry for title it should read Sprite Attacher Not Working
I edited a tiny bit of the sprite attacher but it doesnt seem to work when I try to dynamically load a sprite. Do you know why its not attaching the item?
The code is firing AND its getting added to the object like so:
Note that the slot is there:
And if I manually activate this while the game is running (with a test object there) it does appear and disappear. And the logs show the slot and attachment are valid.
But its NOT appearing on the spine. The slot name is correct, too. Do you know why the sprite is not attaching and showing up?
public class SpriteAttacher : MonoBehaviour
{
// These are the slots that can be accessed
public static readonly string SlOT_HELMET = "helmet";
public static readonly string SlOT_ARMOR = "armor";
public static readonly string SlOT_MAIN_HAND = "mainHand";
public static readonly string SlOT_OFF_HAND = "offHand";
public bool attachOnStart = true;
public bool keepLoaderInMemory = true;
// Example of how to do this in the editor
//[SpineSlot]
//public string slotname;
private SpriteAttachmentLoader loader;
private RegionAttachment attachment;
public void Attach (string slotName, Sprite sprite)
{
var skeletonRenderer = GetComponent<SkeletonRenderer>();
if (loader == null)
//create loader instance, tell it what sprite and shader to use
// ANTHONY: This has been changed from Spine/Skeleton because it has artifacts when it spawns
// Using the Sprites/Default shader fixes this
loader = new SpriteAttachmentLoader(sprite, Shader.Find("Sprites/Default"));
if (attachment == null)
{
attachment = loader.NewRegionAttachment(null, sprite.name, "");
Debug.Log("Created Attachment");
}
// Get the slot and attach the object
Debug.Log("Adding sprite to " + slotName);
skeletonRenderer.skeleton.FindSlot(slotName).Attachment = attachment;
Debug.Log("Added to " + skeletonRenderer.skeleton.FindSlot(slotName).Attachment);
if (!keepLoaderInMemory)
{
loader = null;
}
}
}
Nothing below this changed.