• International中文
  • 如何通过AtlasRegion动态替换MeshAttachment?

大家好,

我在使用Spine-Unity时遇到了一些问题,想请教一下大家。

目前,Spine-Unity提供的AttachmentRegionExtensions可以通过atlasRegion创建一个新的RegionAttachment,方法是使用ToRegionAttachment。不过,我现在需要动态替换一个MeshAttachment,并希望能够使用atlasRegion来创建这个MeshAttachment。

我想知道,有没有类似的方法可以通过atlasRegion直接创建或替换MeshAttachment?或者有没有其他推荐的方式实现这个功能?

非常感谢大家的帮助!

Related Discussions
...

@jonomidi There is no direct equivalent available since creating a mesh attachment for an atlas region is not really reasonable.

Instead you start from an existing MeshAttachment and copy it and set the region accordingly to your desired atlas region. There are convenience methods available here:
AttachmentCloneExtensions.
Note that these are also demonstrated in the example scenes Spine Examples/Other Examples/Mix and Match and Mix and Match Equip (with Unity Sprites instead of Regions to replace mesh attachment regions, but similar in use).

    Harald 非常感谢你的解答!你提供的建议对我非常有帮助!我会根据你的建议去尝试,并参考相关的示例场景来进一步学习。

    • Harald đã thích điều này.

    @jonomidi Glad it helped, thanks for getting back to us!