• International한국어
  • Skeleton Graphic의 Slot정보 추가 기능이 동작하지 않습니다.

  • 已编辑

Skeleton Graphic의 Slot에 새로운 Sprite정보를 가진 Attachment 정보로 교체하여 특정 Slot 정보에 이미지 교체를 처리하고 싶은데요.
Skeleton Animation에서는 정상적으로 동작하는데 Skeleton Graphic에서는 동작하지 않는 이슈가 있는 것 같더라구요..
해당 기능이 안되는지와, 안된다면 특정 부분만을(특정 Slot) Runtime에서 동적으로 Sprite를 등록하여 교체할 수 있는 기능이 있는지가 궁금합니다.

public static void ReplaceAttachmentFromSprite(this SkeletonGraphic skeletonGraphic, string szSpritePath)
{
Material matWeapon = new Material(Shader.Find("Sprites/Default"));
string SlotName = "weapon";
csCommonFunction.ReplaceAttachmentFromSprite(
skeletonGraphic,
matWeapon,
SlotName,
szSpritePath,
0f);
}

public static RegionAttachment ReplaceAttachmentFromSprite(
this SkeletonGraphic skeletonGraphic, Material material, string slotName, string szSpritePath, float rotation = 0f)
{
if (material == null) { return null; }
Sprite sprite = ResourceManager.Instance.GetAsset<Sprite>(szSpritePath);
if (sprite == null) { return null; }
material.mainTexture = sprite.texture;
return ReplaceAttachmentFromSprite(skeletonGraphic.Skeleton, slotName, sprite, material, rotation);
}

public static RegionAttachment ReplaceAttachmentFromSprite(this Skeleton skeleton, string slotName, Sprite sprite, Material material, float rotation = 0f)
{
RegionAttachment att = sprite != null ? sprite.ToRegionAttachment(material, rotation: rotation) : null;
Slot slot = skeleton.FindSlot(slotName);
if (slot != null)
{
slot.Attachment = att;
}
return att;
}

JinHyeok skeletonGraphic

    Related Discussions
    ...

    @JinHyeok Sorry to hear you're having troubles. This is unfortunately not yet supported on 4.2 and planned for 4.3-beta, see this issue ticket here:
    EsotericSoftware/spine-runtimes1982

    Please note that you can surround your multi-line code with triple-backticks "```" to format it correctly.